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

vim-patch:9.0.{2074,2077}: Completion menu may be wrong #25806

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

zeertzjq
Copy link
Member

vim-patch:9.0.2074: Completion menu may be wrong

Problem: Completion menu may be wrong
Solution: Check for the original direction of the completion menu,
add more tests, make it work with 'noselect'

completion: move in right direction when filling completion_info()

When moving through the insert completion menu and switching directions,
we need to make sure we start at the correct position in the list and
move correctly forward/backwards through it, so that we do not skip
entries and the selected item points to the correct entry in the list
of completion entries generated by the completion_info() function.

The general case is this:

  1. CTRL-X CTRL-N, we will traverse the list starting from
    compl_first_match and then go forwards (using the cp->next pointer)
    through the list (skipping the very first entry, which has the
    CP_ORIGINAL_TEXT flag set (since that is the empty/non-selected entry

  2. CTRL-X CTRL-P, we will traverse the list starting from
    compl_first_match (which now points to the last entry). The previous
    entry will have the CP_ORIGINAL_TEXT flag set, so we need to start
    traversing the list from the second prev pointer.

There are in fact 2 special cases after starting the completion menu
with CTRL-X:

  1. CTRL-N and then going backwards by pressing CTRL-P again.
    compl_first_match will point to the same entry as in step 1 above,
    but since compl_dir_foward() has been switched by pressing CTRL-P
    to backwards we need to pretend to be in still in case 1 and still
    traverse the list in forward direction using the cp_next pointer

  2. CTRL-P and then going forwards by pressing CTRL-N again.
    compl_first_match will point to the same entry as in step 2 above,
    but since compl_dir_foward() has been switched by pressing CTRL-N
    to forwards we need to pretend to be in still in case 2 and still
    traverse the list in backward direction using the cp_prev pointer

For the 'noselect' case however, this is slightly different again. When
going backwards, we only need to go one cp_prev pointer back. And
resting of the direction works again slightly different. So we need to
take the noselect option into account when deciding in which direction
to iterate through the list of matches.

related: vim/vim#13402
related: vim/vim#12971
closes: vim/vim#13408

vim/vim@daef8c7

Co-authored-by: Christian Brabandt cb@256bit.org

vim-patch:9.0.2077: CI fails because of trailing whitespace in test

Problem: CI fails because of trailing whitespace in test
Solution: Remove it

vim/vim@87ca5e8

Co-authored-by: Christian Brabandt cb@256bit.org

zeertzjq and others added 2 commits October 28, 2023 06:16
Problem:  Completion menu may be wrong
Solution: Check for the original direction of the completion menu,
          add more tests, make it work with 'noselect'

completion: move in right direction when  filling completion_info()

When moving through the insert completion menu and switching directions,
we need to make sure we start at the correct position in the list and
move correctly forward/backwards through it, so that we do not skip
entries and the selected item points to the correct entry in the list
of completion entries generated by the completion_info() function.

The general case is this:

1) CTRL-X CTRL-N, we will traverse the list starting from
   compl_first_match and then go forwards (using the cp->next pointer)
   through the list (skipping the very first entry, which has the
   CP_ORIGINAL_TEXT flag set (since that is the empty/non-selected entry

2) CTRL-X CTRL-P, we will traverse the list starting from
   compl_first_match (which now points to the last entry). The previous
   entry will have the CP_ORIGINAL_TEXT flag set, so we need to start
   traversing the list from the second prev pointer.

There are in fact 2 special cases after starting the completion menu
with CTRL-X:

3)  CTRL-N and then going backwards by pressing CTRL-P again.
    compl_first_match will point to the same entry as in step 1 above,
    but since compl_dir_foward() has been switched by pressing CTRL-P
    to backwards we need to pretend to be in still in case 1 and still
    traverse the list in forward direction using the cp_next pointer

4)  CTRL-P and then going forwards by pressing CTRL-N again.
    compl_first_match will point to the same entry as in step 2 above,
    but since compl_dir_foward() has been switched by pressing CTRL-N
    to forwards we need to pretend to be in still in case 2 and still
    traverse the list in backward direction using the cp_prev pointer

For the 'noselect' case however, this is slightly different again. When
going backwards, we only need to go one cp_prev pointer back. And
resting of the direction works again slightly different. So we need to
take the noselect option into account when deciding in which direction
to iterate through the list of matches.

related: vim/vim#13402
related: vim/vim#12971
closes: vim/vim#13408

vim/vim@daef8c7

Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem:  CI fails because of trailing whitespace in test
Solution: Remove it

vim/vim@87ca5e8

Co-authored-by: Christian Brabandt <cb@256bit.org>
@zeertzjq zeertzjq changed the title vim-patch:9.0.2074,9.0.2077 vim-patch:9.0.{2074,2077}: Completion menu may be wron Oct 27, 2023
@zeertzjq zeertzjq changed the title vim-patch:9.0.{2074,2077}: Completion menu may be wron vim-patch:9.0.{2074,2077}: Completion menu may be wrong Oct 27, 2023
@github-actions github-actions bot added the vim-patch See https://neovim.io/doc/user/dev_vimpatch.html label Oct 27, 2023
@zeertzjq zeertzjq merged commit d2e7cc6 into neovim:master Oct 27, 2023
23 checks passed
@zeertzjq zeertzjq deleted the vim-9.0.2074 branch October 27, 2023 22:44
@github-actions github-actions bot removed the request for review from seandewar October 27, 2023 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vim-patch See https://neovim.io/doc/user/dev_vimpatch.html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant