Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ユーザー定義コマンドの補完の関数内で execute() を実行すると結果が得られない #1129

Closed
thinca opened this issue Dec 16, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@thinca
Copy link
Member

commented Dec 16, 2017

質問・報告の内容

例えば以下のように、ユーザー定義コマンドに対して補完関数を設定し、その補完関数内で execute() 関数を使って結果を得ようとすると、結果が常に空文字列になります。

function! Complete(arglist, cmdline, cursorpos) abort
  let s = execute('echo "hi"')
  return s
endfunction

command! -nargs=* -complete=custom,Complete Test :

-complete=customlist-complete=custom と同様になります。

Vimのバージョン

8.0.1387

OSの種類/ディストリ/バージョン

確認した環境:

  • Gentoo Linux
@ichizok

This comment has been minimized.

Copy link
Member

commented Dec 18, 2017

--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -2886,6 +2886,7 @@ f_execute(typval_T *argvars, typval_T *rettv)
     int                save_emsg_silent = emsg_silent;
     int                save_emsg_noredir = emsg_noredir;
     int                save_redir_execute = redir_execute;
+    int                save_redir_off = redir_off;
     garray_T   save_ga;
 
     rettv->vval.v_string = NULL;
@@ -2928,6 +2929,7 @@ f_execute(typval_T *argvars, typval_T *rettv)
        save_ga = redir_execute_ga;
     ga_init2(&redir_execute_ga, (int)sizeof(char), 500);
     redir_execute = TRUE;
+    redir_off = FALSE;
 
     if (cmd != NULL)
        do_cmdline_cmd(cmd);
@@ -2956,6 +2958,7 @@ f_execute(typval_T *argvars, typval_T *rettv)
     emsg_noredir = save_emsg_noredir;
 
     redir_execute = save_redir_execute;
+    redir_off = save_redir_off;
     if (redir_execute)
        redir_execute_ga = save_ga;
 
@ichizok

This comment has been minimized.

Copy link
Member

commented Dec 18, 2017

さしあたり execute() 内で redir_off を解除すればよいですが、もっと適切なフローがあるかも。

@thinca

This comment has been minimized.

Copy link
Member Author

commented Dec 21, 2017

パッチ適用して動作確認してみました。問題の現象は直っているようです。ありがとうございます!

他の範囲への影響はちょっとわからないですが、他に意見ないようであれば提出してみるのが良さそうです。

@ichizok

This comment has been minimized.

Copy link
Member

commented Dec 24, 2017

vim/vim#2492
投げました。

@ichizok

This comment has been minimized.

Copy link
Member

commented Dec 25, 2017

8.0.1425
vim/vim@2095148

@ichizok ichizok closed this Dec 25, 2017

@ichizok ichizok added the xlose/fixed label Dec 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.