Loading ...
Sorry, an error occurred while loading the content.
 

Re: :redir make confusion of cursor position in command line.

Expand Messages
  • mattn
    Yes, mingw32, -u NONE -N. -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you are replying to. For
    Message 1 of 9 , Oct 3, 2011
      Yes, mingw32, -u NONE -N.

      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Bram Moolenaar
      ... I still cannot reproduce the problem. It does not look like it is specific for Windows. I think saving and restoring msg_row and msg_col in :redir will
      Message 2 of 9 , Dec 14, 2011
        Yasuhiro Matsumoto wrote:

        > Try following on windows.
        >
        > ---- script1 ----
        > function! DoSpace()
        > return ' '
        > endfunction
        > cnoremap <expr> <space> DoSpace()
        > ----
        >
        > ---- script2 ----
        > function! DoSpace()
        > redir => foo
        > silent! command
        > redir END
        > return ' '
        > endfunction
        > cnoremap <expr> <space> DoSpace()
        > ----
        >
        > When run script1 and type ":XXX " in normal mode, you'll see ":XXX ".
        > But if run script2 and type it, it show " XXX ". You can see ":" is erased
        > in command line.
        >
        > The cause is:
        > Doing redir and something that updating cursor position in scripts are
        > change msg_col even if command use silent!. This is not a problem. But if
        > enter "redir END" for <expr> function, msg_col should be restored to
        > original position that is started with ":redir foo".
        >
        > Below is a patch. Please check this.

        I still cannot reproduce the problem. It does not look like it is
        specific for Windows.

        I think saving and restoring msg_row and msg_col in ":redir" will not
        work well. It's probably better to do this while evaluating the
        expression. Please try out this patch instead of yours:


        *** ../vim-7.3.377/src/getchar.c 2011-10-12 22:02:07.000000000 +0200
        --- src/getchar.c 2011-12-14 18:37:52.000000000 +0100
        ***************
        *** 4510,4515 ****
        --- 4510,4517 ----
        char_u *expr;
        char_u *save_cmd;
        pos_T save_cursor;
        + int save_msg_col;
        + int save_msg_row;

        /* Remove escaping of CSI, because "str" is in a format to be used as
        * typeahead. */
        ***************
        *** 4533,4544 ****
        --- 4535,4550 ----
        #endif
        set_vim_var_char(c); /* set v:char to the typed character */
        save_cursor = curwin->w_cursor;
        + save_msg_col = msg_col;
        + save_msg_row = msg_row;
        p = eval_to_string(expr, NULL, FALSE);
        --textlock;
        #ifdef FEAT_EX_EXTRA
        --ex_normal_lock;
        #endif
        curwin->w_cursor = save_cursor;
        + msg_col = save_msg_col;
        + msg_row = save_msg_row;

        restore_cmdline_alloc(save_cmd);
        vim_free(expr);


        --
        DINGO: And after the spanking ... the oral sex.
        GALAHAD: Oh, dear! Well, I...
        GIRLS: The oral sex ... The oral sex.
        GALAHAD: Well, I suppose I could stay a BIT longer.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • mattn
        It seems good to me. :) -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you are replying to. For more
        Message 3 of 9 , Dec 14, 2011
          It seems good to me. :)

          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.