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

'omnifunc' の第一引数 a:findstart の型に一貫性がない #1168

Closed
machakann opened this issue May 21, 2018 · 11 comments
Closed

'omnifunc' の第一引数 a:findstart の型に一貫性がない #1168

machakann opened this issue May 21, 2018 · 11 comments

Comments

@machakann
Copy link

質問・報告の内容

確認方法

  1. 以下の内容のファイルを保存し、 :source コマンドで読み込む
function! TestOmni(findstart, base) abort
  echomsg string([a:findstart, type(a:findstart) is# v:t_number])
  if a:findstart == 1
    return -1
  endif
  return []
endfunction
setlocal omnifunc=TestOmni
  1. インサートモードに入り、 <C-x><C-o> と入力

  2. ノーマルモードに戻り :message コマンドで出力を確認する


期待するのは

[1, 1]
[0, 1]

という出力ですが、実際には

['1', 0]
[0, 1]

と、一回目の呼び出しでは数字の 1 ではなく文字列の '1' が渡されています。 :help complete-functions では a:findstart が数値とは明言されていませんが、数値を期待するのが自然かと思います。また、少なくとも数値か文字列かどちらかに統一されている方がよいと思います。

Vimのバージョン

8.1.10

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

  • Windows 10 Education 64bit (10.0.17134.48)
@koron
Copy link
Member

koron commented May 21, 2018

最初に作ったときは数字の 1 のつもりで作りました。

どういう経緯で "1" になってしまったのかは謎。

@ichizok
Copy link
Member

ichizok commented May 21, 2018

v7.3.614
vim/vim@0cbba94
多分ここから動作が変わった (number → string) のではないかと

@machakann
Copy link
Author

machakann commented May 22, 2018

call_func_retnr() の引数を call_vim_function() の仕様にあわせて増やす、という方法でどうでしょう?

https://gist.github.com/machakann/ef78414c6fd696ebc68987cfcd85ac77

@ichizok
Copy link
Member

ichizok commented May 23, 2018

最初から argvtypval_T で渡した方がよさそう
https://github.com/vim/vim/compare/master...ichizok:fix/complfunc-args.diff

@machakann
Copy link
Author

こっちのほうが根本的解決みたいですね。 @ichizok さんのパッチでお願いします。

@ichizok
Copy link
Member

ichizok commented Jun 8, 2018

PRed.
vim/vim#2993

@ichizok
Copy link
Member

ichizok commented Jun 13, 2018

v8.1.0053
vim/vim@ffa9684

@h-east
Copy link
Member

h-east commented Jun 13, 2018

8.1.0053
vim/vim@ffa9684
数値に統一。

動作上は問題ないけど、testdir/test_ins_complete.vim に足されたテストのassert_equal()の第1引数と第2引数逆ですね。
{expected}, {actual}{actual}, {expected}になっている。☺️

(追記: うぉー。被ったw)

@machakann
Copy link
Author

ありがとうございました!

@ichizok
Copy link
Member

ichizok commented Jun 13, 2018

@h-east ありがとうございます。追加で修正出しました
vim/vim#2993 (comment)

@h-east
Copy link
Member

h-east commented Jun 14, 2018

8.1.0055 👍
vim/vim@52d3aae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants