Rewrite popup menu positioning logic and fix bugs#18441
Rewrite popup menu positioning logic and fix bugs#18441girishji wants to merge 5 commits intovim:masterfrom
Conversation
- Simplified and rewrote horizontal positioning logic (was overly complex). - Split horizontal and vertical positioning into separate functions. - Fixed missing truncation marker (e.g. >) when items were truncated and pummaxwidth was not set. - Fixed occasional extra space being added to menu items.
M src/popupmenu.c M src/testdir/test_popupwin.vim
M src/testdir/test_popupwin.vim
|
This issue occurs only in the test; I cannot reproduce it otherwise. If anyone has suggestions, please let me know. |
`Test_popupwin_infopopup_6.dump` and `Test_popupwin_infopopup_7.dump` are already incorrect: they show the info window but not the popup menu. This issue occurs only in the test; I cannot reproduce it otherwise. In `Test_popupmenu_info_border()`, setting of `pumheight=3` causes the problem. Without `pumheight`, the popup menu displays correctly, but `pumheight` is needed for the test. Work around is to add `:set completepopup=border:off` to failing tests.
|
thanks |
|
thanks. |
|
This regresses the following change from #17081: diff --git a/src/testdir/dumps/Test_pum_maxwidth_07.dump b/src/testdir/dumps/Test_pum_maxwidth_07.dump
index ada8acb0d..112e1f588 100644
--- a/src/testdir/dumps/Test_pum_maxwidth_07.dump
+++ b/src/testdir/dumps/Test_pum_maxwidth_07.dump
@@ -1,7 +1,7 @@
|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_> @44
|1+0#0000001#e0e0e08|2|3|4|5|6|7|8|9|>| +0#4040ff13#ffffff0@64
|一*0#0000001#ffd7ff255|二|三|四| +&|>| +0#4040ff13#ffffff0@64
-|a+0#0000001#ffd7ff255|b|c|d|e|f|g|h|i|>| +0#4040ff13#ffffff0@64
+|a+0#0000001#ffd7ff255|b|c|d|e|f|g|h|i|j| +0#4040ff13#ffffff0@64
|上*0#0000001#ffd7ff255|下|左|右| +&@1| +0#4040ff13#ffffff0@64
|~| @73
|~| @73
diff --git a/src/testdir/dumps/Test_pum_maxwidth_08.dump b/src/testdir/dumps/Test_pum_maxwidth_08.dump
index aa41b76d1..9f92ae706 100644
--- a/src/testdir/dumps/Test_pum_maxwidth_08.dump
+++ b/src/testdir/dumps/Test_pum_maxwidth_08.dump
@@ -1,7 +1,7 @@
| +0&#ffffff0@43> |_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
| +0#4040ff13&@64|<+0#0000001#e0e0e08|9|8|7|6|5|4|3|2|1
| +0#4040ff13#ffffff0@64|<+0#0000001#ffd7ff255| |四*&|三|二|一
-| +0#4040ff13#ffffff0@64|<+0#0000001#ffd7ff255|i|h|g|f|e|d|c|b|a
+| +0#4040ff13#ffffff0@64|j+0#0000001#ffd7ff255|i|h|g|f|e|d|c|b|a
| +0#4040ff13#ffffff0@64| +0#0000001#ffd7ff255@1|右*&|左|下|上
| +0#4040ff13#ffffff0@73|~
| @73|~Now |
|
There’s currently an extra space (or truncation character) after each item. If |
|
It's the same issue. I think removing |
This PR introduces a new global option, `'pumborder'` (`'pb'`), that allows
users to define borders and optional decorations for the completion popup
menu.
```
*'pumborder'* *'pb'*
'pumborder' 'pb' number (default 0)
global
Defines a border and optional decorations for the popup menu in
completion. The value is a comma-separated list of keywords.
Border styles (at most one):
"single" use thin box-drawing characters
"double" use double-line box-drawing characters
"round" use rounded corners
"ascii" use ASCII characters (-, |, +)
"custom:XXXXXXXX"
use eight characters given after "custom:",
in order: top, right, bottom, left,
topleft, topright, botright, botleft
Additional flags:
"margin" adds one-cell spacing inside the left and right border
"shadow" draws a shadow at the right and bottom edges
Highlight groups:
|hl-PmenuBorder| used for the border characters
|hl-PmenuShadow| used for the shadow
Examples: >
:set pumborder=single
:set pumborder=double,margin,shadow
:set pumborder=custom:─│─│┌┐┘└,shadow
<
Border styles using box-drawing characters ("single", "double",
"round") are only available when |'encoding'| is "utf-8" and
|'ambiwidth'| is "single". "margin" requires a border style.
See also: |ins-completion-menu|.
```
Also, fixes vim#18441 (comment)
*(Add screenshot)*
This PR introduces a new global option, `'pumborder'` (`'pb'`), that allows
users to define borders and optional decorations for the completion popup
menu.
```
*'pumborder'* *'pb'*
'pumborder' 'pb' number (default 0)
global
Defines a border and optional decorations for the popup menu in
completion. The value is a comma-separated list of keywords.
Border styles (at most one):
"single" use thin box-drawing characters
"double" use double-line box-drawing characters
"round" use rounded corners
"ascii" use ASCII characters (-, |, +)
"custom:XXXXXXXX"
use eight characters given after "custom:",
in order: top, right, bottom, left,
topleft, topright, botright, botleft
Additional flags:
"margin" adds one-cell spacing inside the left and right border
"shadow" draws a shadow at the right and bottom edges
Highlight groups:
|hl-PmenuBorder| used for the border characters
|hl-PmenuShadow| used for the shadow
Examples: >
:set pumborder=single
:set pumborder=double,margin,shadow
:set pumborder=custom:─│─│┌┐┘└,shadow
<
Border styles using box-drawing characters ("single", "double",
"round") are only available when |'encoding'| is "utf-8" and
|'ambiwidth'| is "single". "margin" requires a border style.
See also: |ins-completion-menu|.
```
Also, fixes vim#18441 (comment)
Problem: not possible to style popup borders globally
Solution: Add the 'pumborder' option (Girish Palya)
This commit introduces a new global option, 'pumborder' ('pb'), that
allows users to define borders and optional decorations for the
completion popup menu.
```
Defines a border and optional decorations for the popup menu in
completion. The value is a comma-separated list of keywords.
Border styles (at most one):
"single"singleuse thin box-drawing characters
"double"doubleuse double-line box-drawing characters
"round"rounduse rounded corners
"ascii"asciiuse ASCII characters (-, |, +)
"custom:XXXXXXXX"
use eight characters given after "custom:",
in order: top, right, bottom, left,
topleft, topright, botright, botleft
Additional flags:
"margin"marginadds one-cell spacing inside the left and right border
"shadow"shadowdraws a shadow at the right and bottom edges
Highlight groups:
|hl-PmenuBorder|hl-PmenuBorderused for the border characters
|hl-PmenuShadow|hl-PmenuShadowused for the shadow
Examples: >
:set pumborder=single
:set pumborder=double,margin,shadow
:set pumborder=custom:─│─│┌┐┘└,shadow
Border styles using box-drawing characters ("single", "double",
"round") are only available when |'encoding'| is "utf-8" and
|'ambiwidth'| is "single". "margin" requires a border style.
See also: |ins-completion-menu|.
```
fixes: #18441 (comment)
closes: #18486
closes: #17091
Signed-off-by: Girish Palya <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
Problem: not possible to style popup borders globally
Solution: Add the 'pumborder' option (Girish Palya)
This commit introduces a new global option, 'pumborder' ('pb'), that
allows users to define borders and optional decorations for the
completion popup menu.
```
Defines a border and optional decorations for the popup menu in
completion. The value is a comma-separated list of keywords.
Border styles (at most one):
"single"singleuse thin box-drawing characters
"double"doubleuse double-line box-drawing characters
"round"rounduse rounded corners
"ascii"asciiuse ASCII characters (-, |, +)
"custom:XXXXXXXX"
use eight characters given after "custom:",
in order: top, right, bottom, left,
topleft, topright, botright, botleft
Additional flags:
"margin"marginadds one-cell spacing inside the left and right border
"shadow"shadowdraws a shadow at the right and bottom edges
Highlight groups:
|hl-PmenuBorder|hl-PmenuBorderused for the border characters
|hl-PmenuShadow|hl-PmenuShadowused for the shadow
Examples: >
:set pumborder=single
:set pumborder=double,margin,shadow
:set pumborder=custom:─│─│┌┐┘└,shadow
Border styles using box-drawing characters ("single", "double",
"round") are only available when |'encoding'| is "utf-8" and
|'ambiwidth'| is "single". "margin" requires a border style.
See also: |ins-completion-menu|.
```
fixes: vim#18441 (comment)
closes: vim#18486
closes: vim#17091
Signed-off-by: Girish Palya <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
Problem: popup: there are some position logic bugs
Solution: Refactor position logic and fix a few bugs
(Girish Palya).
This change does the following:
- Simplified and rewrote horizontal positioning logic (was overly
complex).
- Split horizontal and vertical positioning into separate functions.
- Fixed missing truncation marker (e.g. `>`) when items were truncated
and `pummaxwidth` was not set.
- Fixed occasional extra space being added to menu items.
- Update tests
closes: vim/vim#18441
vim/vim@e3ed558
Cherry-pick pum_display_{rtl,ltr}_text() changes from patch 9.1.1835.
Co-authored-by: Girish Palya <[email protected]>
Problem: popup: there are some position logic bugs
Solution: Refactor position logic and fix a few bugs
(Girish Palya).
This change does the following:
- Simplified and rewrote horizontal positioning logic (was overly
complex).
- Split horizontal and vertical positioning into separate functions.
- Fixed missing truncation marker (e.g. `>`) when items were truncated
and `pummaxwidth` was not set.
- Fixed occasional extra space being added to menu items.
- Update tests
closes: vim/vim#18441
vim/vim@e3ed558
Cherry-pick pum_display_{rtl,ltr}_text() changes from patch 9.1.1835.
Co-authored-by: Girish Palya <[email protected]>
Problem: popup: there are some position logic bugs
Solution: Refactor position logic and fix a few bugs
(Girish Palya).
This change does the following:
- Simplified and rewrote horizontal positioning logic (was overly
complex).
- Split horizontal and vertical positioning into separate functions.
- Fixed missing truncation marker (e.g. `>`) when items were truncated
and `pummaxwidth` was not set.
- Fixed occasional extra space being added to menu items.
- Update tests
closes: vim/vim#18441
vim/vim@e3ed558
Cherry-pick pum_display_{rtl,ltr}_text() changes from patch 9.1.1835.
Co-authored-by: Girish Palya <[email protected]>

Refactor
Bug fixes
>) when items were truncated andpummaxwidthwas not set.