-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
infinite loop when adjusting vertical split size with mouse with smoothscroll + number + showbreak + scrolloff #14750
Comments
Hm,
The following patch fixes it for me (and it doesn't seem to cause any regressions), but I am not hundert percent sure. diff --git a/src/charset.c b/src/charset.c
index 470698f0e..e47b679f5 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -770,6 +770,9 @@ linetabsize_col(int startcol, char_u *s)
while (*cts.cts_ptr != NUL)
cts.cts_vcol += lbr_chartabsize_adv(&cts);
clear_chartabsize_arg(&cts);
+ // overflow, e.g. because of a small window when the start of the line is no longer visible
+ if (cts.cts_vcol < 0)
+ return MAXCOL;
return (int)cts.cts_vcol;
}
@@ -784,6 +787,9 @@ win_linetabsize(win_T *wp, linenr_T lnum, char_u *line, colnr_T len)
init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
win_linetabsize_cts(&cts, len);
clear_chartabsize_arg(&cts);
+ // overflow, e.g. because of a small window when the start of the line is no longer visible
+ if (cts.cts_vcol < 0)
+ return MAXCOL;
return (int)cts.cts_vcol;
}
diff --git a/src/move.c b/src/move.c
index 3e589caae..fe820ef07 100644
--- a/src/move.c
+++ b/src/move.c
@@ -1630,6 +1630,7 @@ static void cursor_correct_sms(void)
int width2 = width1 + curwin_col_off2();
int so_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
int space_cols = (curwin->w_height - 1) * width2;
+ int overlap, top, bot;
int size = so == 0 ? 0 : win_linetabsize(curwin, curwin->w_topline,
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
@@ -1639,16 +1640,16 @@ static void cursor_correct_sms(void)
so_cols = space_cols / 2; // Not enough room: put cursor in the middle.
// Not enough screen lines in topline: ignore 'scrolloff'.
- while (so_cols > size && so_cols - width2 >= width1)
+ while (so_cols > size && so_cols - width2 >= width1 && width1 > 0 && size > 0)
so_cols -= width2;
if (so_cols >= width1 && so_cols > size)
so_cols -= width1;
// If there is no marker or we have non-zero scrolloff, just ignore it.
- int overlap = (curwin->w_skipcol == 0 || so_cols != 0) ? 0
+ overlap = (curwin->w_skipcol == 0 || so_cols != 0) ? 0
: sms_marker_overlap(curwin, -1);
- int top = curwin->w_skipcol + overlap + so_cols;
- int bot = curwin->w_skipcol + width1 + (curwin->w_height - 1) * width2
+ top = curwin->w_skipcol + overlap + so_cols;
+ bot = curwin->w_skipcol + width1 + (curwin->w_height - 1) * width2
- so_cols;
validate_virtcol();
colnr_T col = curwin->w_virtcol; @luukvbaal what do you think? |
Yeah avoiding to return overflown value seems desirable. I also don't foresee it causing any issues when returning |
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative fixes: vim#14750 Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, also verify that win_linetabsize does not overflow fixes: vim#14750 Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, also verify that win_linetabsize does not overflow fixes: vim#14750 Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, also verify that win_linetabsize does not overflow fixes: vim#14750 Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, verify that win_linetabsize does not overflow fixes: vim/vim#14750 closes: vim/vim#14772 vim/vim@eff20eb Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, verify that win_linetabsize does not overflow fixes: vim/vim#14750 closes: vim/vim#14772 vim/vim@eff20eb Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, verify that win_linetabsize does not overflow fixes: vim/vim#14750 closes: vim/vim#14772 vim/vim@eff20eb Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, verify that win_linetabsize does not overflow fixes: vim/vim#14750 closes: vim/vim#14772 vim/vim@eff20eb Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: smoothscroll may cause infinite loop, with very narrow windows (Jaehwang Jung, after v9.1.0280) Solution: Check for width1 being negative, verify that win_linetabsize does not overflow fixes: vim/vim#14750 closes: vim/vim#14772 vim/vim@eff20eb Co-authored-by: Christian Brabandt <cb@256bit.org>
Steps to reproduce
Expected behaviour
no infinite loop
Version of Vim
9.1.0407
Environment
ubuntu 22.04
Logs and stack traces
The text was updated successfully, but these errors were encountered: