Skip to content

Add setcmdline()#10869

Closed
Shougo wants to merge 15 commits intovim:masterfrom
Shougo:setcmdline
Closed

Add setcmdline()#10869
Shougo wants to merge 15 commits intovim:masterfrom
Shougo:setcmdline

Conversation

@Shougo
Copy link
Contributor

@Shougo Shougo commented Aug 9, 2022

It is useful to create plugins for command line.

@brammool
Copy link
Contributor

brammool commented Aug 9, 2022

I wonder what happens when calling setcmdline() while in custom completion. Should have a test for that.
There might be other situations where changing the command line unexpectedly might cause trouble.

@Shougo
Copy link
Contributor Author

Shougo commented Aug 11, 2022

I wonder what happens when calling setcmdline() while in custom completion.

What means the custom completion?
It is command custom completion? To add tests, I need to understand it.

@brammool
Copy link
Contributor

brammool commented Aug 11, 2022 via email

@Shougo
Copy link
Contributor Author

Shougo commented Aug 14, 2022

I have added tests.

@Shougo
Copy link
Contributor Author

Shougo commented Aug 14, 2022

Failures: 
	From test_cmdline.vim:
	Found errors in Test_setcmdline():
	command line..script /home/runner/work/vim/vim/src/testdir/runtest.vim[468]..function RunTheTest[44]..Test_setcmdline line 33: Expected 'let foo=0' but got '"DoCmd January February Mars'

I don't know why it is failed in gvim only.
It works for me...

@Shougo
Copy link
Contributor Author

Shougo commented Aug 14, 2022

I have changed the map character. It is passed.

@vimpostor
Copy link
Contributor

Do you have an example usecase for this function? I don't quite get where this is useful.

@bfrg
Copy link
Contributor

bfrg commented Aug 14, 2022

Do you have an example usecase for this function? I don't quite get where this is useful.

  1. Custom command-line popup window (the popup callback function calls setcmdline() to set the command-line after user made selection and hit ENTER)
  2. If someone has a user command with a command-completion function that obtains its list of candidates asynchronously the job callback function needs a way to set the command-line once the list of candidates are obtained.

@habamax
Copy link
Contributor

habamax commented Aug 15, 2022

  1. Custom command-line popup window (the popup callback function calls setcmdline() to set the command-line after user made selection and hit ENTER)

I for now use feedkeys(":Command") to have it, I guess proper function would be better.

@brammool
Copy link
Contributor

A few review comments (sorry it took a while):

  • please use the same formatting as for other functions (function return type goes on a separate line)
  • help says returning FALSE or TRUE, but it looks like it's returning one and zero
  • use a better error than e_invalid_argument
  • a negative position is rejected without any error
  • All declarations go at the start of the block (ANSI C)

@Shougo
Copy link
Contributor Author

Shougo commented Aug 27, 2022

help says returning FALSE or TRUE, but it looks like it's returning one and zero

yes, but it is the same behavior with setcmdpos(). The documentation is wrong??

@Shougo
Copy link
Contributor Author

Shougo commented Aug 27, 2022

please use the same formatting as for other functions (function return type goes on a separate line)

Fixed.

a negative position is rejected without any error

Fixed.

All declarations go at the start of the block (ANSI C)

Fixed.

@codecov
Copy link

codecov bot commented Aug 27, 2022

Codecov Report

Merging #10869 (35d8b0f) into master (5ff595d) will increase coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #10869      +/-   ##
==========================================
+ Coverage   82.40%   82.49%   +0.08%     
==========================================
  Files         152      152              
  Lines      177500   177529      +29     
  Branches    40279    40283       +4     
==========================================
+ Hits       146272   146455     +183     
+ Misses      19043    18906     -137     
+ Partials    12185    12168      -17     
Flag Coverage Δ
huge-clang-none 82.70% <100.00%> (+<0.01%) ⬆️
huge-gcc-none 55.58% <100.00%> (+<0.01%) ⬆️
huge-gcc-testgui 54.01% <100.00%> (?)
huge-gcc-unittests 0.30% <0.00%> (-0.01%) ⬇️
linux 82.49% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/evalfunc.c 90.73% <ø> (+0.53%) ⬆️
src/ex_getln.c 83.75% <100.00%> (+0.21%) ⬆️
src/if_xcmdsrv.c 77.40% <0.00%> (-0.18%) ⬇️
src/channel.c 83.43% <0.00%> (-0.14%) ⬇️
src/gui.c 69.72% <0.00%> (-0.05%) ⬇️
src/quickfix.c 90.92% <0.00%> (+0.02%) ⬆️
src/window.c 86.54% <0.00%> (+0.03%) ⬆️
src/diff.c 83.31% <0.00%> (+0.06%) ⬆️
src/ex_docmd.c 91.79% <0.00%> (+0.07%) ⬆️
src/vim9cmds.c 86.64% <0.00%> (+0.08%) ⬆️
... and 21 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@brammool
Copy link
Contributor

brammool commented Aug 27, 2022 via email

@brammool brammool closed this in 07ea5f1 Aug 27, 2022
@Shougo Shougo deleted the setcmdline branch August 28, 2022 05:55
@Shougo
Copy link
Contributor Author

Shougo commented Aug 28, 2022

Thank you for the merge.

Shougo added a commit to Shougo/neovim that referenced this pull request Aug 28, 2022
…plugin

Problem:    It is not easy to change the command line from a plugin.
Solution:   Add setcmdline(). (Shougo Matsushita, closes vim/vim#10869)
vim/vim@07ea5f1
zeertzjq pushed a commit to neovim/neovim that referenced this pull request Aug 29, 2022
…plugin (#19979)

vim-patch:9.0.0285: it is not easy to change the command line from a plugin

Problem:    It is not easy to change the command line from a plugin.
Solution:   Add setcmdline(). (Shougo Matsushita, closes vim/vim#10869)
vim/vim@07ea5f1
smjonas pushed a commit to smjonas/neovim that referenced this pull request Dec 31, 2022
…plugin (neovim#19979)

vim-patch:9.0.0285: it is not easy to change the command line from a plugin

Problem:    It is not easy to change the command line from a plugin.
Solution:   Add setcmdline(). (Shougo Matsushita, closes vim/vim#10869)
vim/vim@07ea5f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants