-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Allow non-fixed popups to be shifted even when wrap
is set
#16247
Conversation
The behaviour regarding cutting off the right edge padding did not change with the pull request. I am not sure what you mean by the last part:
EDIT: Maybe I'm wrong about the right edge paddig getting cut off before. |
What I meant was that there's an extra empty line displayed in the popup (see the 2nd screenshot above). |
Got it. The second problem is caused by shifting left mutating Recording of the fix: https://asciinema.org/a/Ha8ciJG5veAuvWqToImDlzOIb Diff: diff --git a/src/popupwin.c b/src/popupwin.c
index 404549097..417533016 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1444,15 +1444,18 @@ popup_adjust_position(win_T *wp)
if (shift_by > wp->w_wincol)
{
- int truncate_shift = shift_by - wp->w_wincol;
-
- shift_by -= truncate_shift;
+ shift_by -= shift_by - wp->w_wincol;
+ if (wp->w_p_wrap)
+ {
+ maxwidth -= right_extra;
+ }
}
wp->w_wincol -= shift_by;
maxwidth += shift_by;
wp->w_width = maxwidth;
}
+ len = linetabsize(wp, lnum);
if (wp->w_p_wrap)
{
while (len + margin_width > maxwidth) I don't see a good way of testing this except with the screendump tests. Unfortunately, I don't yet know how they work and won't be near my computer for the next 10 days. |
@bfrg can you please test it? Regarading the screendump tests. It's not so hard. Have a look at e.g. this one here: vim/src/testdir/test_popupwin.vim Lines 9 to 25 in 92195ae
Now when you first run it, you will find the "failed" screendump file inside |
This patch works better: diff --git a/src/popupwin.c b/src/popupwin.c
index 404549097..10cc12221 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1444,14 +1444,17 @@ popup_adjust_position(win_T *wp)
if (shift_by > wp->w_wincol)
{
- int truncate_shift = shift_by - wp->w_wincol;
-
- shift_by -= truncate_shift;
+ shift_by -= shift_by - wp->w_wincol;
+ if (wp->w_p_wrap)
+ {
+ maxwidth -= right_extra;
+ }
}
wp->w_wincol -= shift_by;
maxwidth += shift_by;
wp->w_width = maxwidth;
+ len = linetabsize(wp, lnum);
}
if (wp->w_p_wrap)
{ Still, if the text is wide, but does not wrap yet, and it gets shifted, then there's a Another recording: |
As discussed, this is the implementation of #16231
This pull request makes it possible for a popup window to use both,
fixed == 0
andwrap == 1
.This is achieved by first shifting the window to the left until it is either fully visible or is moved all the way to the left.
Then, if the popup window is all the way to the left and some line is still too long to fit on screen, wrapping is performed.