mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Problem: Cursor displayed in wrong position after removing text prop. (Ben Jackson) Solution: Invalidate the cursor position. (closes #10898)
This commit is contained in:
@@ -801,6 +801,7 @@ deleted_lines_mark(linenr_T lnum, long count)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Marks the area to be redrawn after a change.
|
* Marks the area to be redrawn after a change.
|
||||||
|
* Consider also calling changed_line_display_buf().
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
changed_lines_buf(
|
changed_lines_buf(
|
||||||
|
16
src/move.c
16
src/move.c
@@ -593,6 +593,22 @@ changed_line_abv_curs_win(win_T *wp)
|
|||||||
|VALID_CHEIGHT|VALID_TOPLINE);
|
|VALID_CHEIGHT|VALID_TOPLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display of line has changed for "buf", invalidate cursor position and
|
||||||
|
* w_botline.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
changed_line_display_buf(buf_T *buf)
|
||||||
|
{
|
||||||
|
win_T *wp;
|
||||||
|
|
||||||
|
FOR_ALL_WINDOWS(wp)
|
||||||
|
if (wp->w_buffer == buf)
|
||||||
|
wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL
|
||||||
|
|VALID_CROW|VALID_CHEIGHT
|
||||||
|
|VALID_TOPLINE|VALID_BOTLINE|VALID_BOTLINE_AP);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the value of curwin->w_botline is valid.
|
* Make sure the value of curwin->w_botline is valid.
|
||||||
*/
|
*/
|
||||||
|
@@ -11,6 +11,7 @@ void changed_cline_bef_curs(void);
|
|||||||
void changed_cline_bef_curs_win(win_T *wp);
|
void changed_cline_bef_curs_win(win_T *wp);
|
||||||
void changed_line_abv_curs(void);
|
void changed_line_abv_curs(void);
|
||||||
void changed_line_abv_curs_win(win_T *wp);
|
void changed_line_abv_curs_win(win_T *wp);
|
||||||
|
void changed_line_display_buf(buf_T *buf);
|
||||||
void validate_botline(void);
|
void validate_botline(void);
|
||||||
void validate_botline_win(win_T *wp);
|
void validate_botline_win(win_T *wp);
|
||||||
void invalidate_botline(void);
|
void invalidate_botline(void);
|
||||||
|
8
src/testdir/dumps/Test_prop_with_text_cursormoved_1.dump
Normal file
8
src/testdir/dumps/Test_prop_with_text_cursormoved_1.dump
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|t+0&#ffffff0|h|i|s| >i|s| |l|i|n|e| |o|n|e|x+0#ffffff16#ff404010@43
|
||||||
|
@60
|
||||||
|
@16| +0#0000000#ffffff0@43
|
||||||
|
|t|h|i|s| |i|s| |l|i|n|e| |t|w|o| @43
|
||||||
|
|t|h|r|e@1| @54
|
||||||
|
|f|o|u|r| @55
|
||||||
|
|f|i|v|e| @55
|
||||||
|
@42|1|,|6| @10|A|l@1|
|
8
src/testdir/dumps/Test_prop_with_text_cursormoved_2.dump
Normal file
8
src/testdir/dumps/Test_prop_with_text_cursormoved_2.dump
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|t+0&#ffffff0|h|i|s| |i|s| |l|i|n|e| |o|n|e| @43
|
||||||
|
|t|h|i|s| >i|s| |l|i|n|e| |t|w|o| @43
|
||||||
|
|t|h|r|e@1| @54
|
||||||
|
|f|o|u|r| @55
|
||||||
|
|f|i|v|e| @55
|
||||||
|
|~+0#4040ff13&| @58
|
||||||
|
|~| @58
|
||||||
|
| +0#0000000&@41|2|,|6| @10|A|l@1|
|
@@ -2775,6 +2775,45 @@ func Test_props_with_text_below_nowrap()
|
|||||||
call delete('XscriptPropsBelowNowrap')
|
call delete('XscriptPropsBelowNowrap')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_props_with_text_CursorMoved()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
call setline(1, ['this is line one', 'this is line two', 'three', 'four', 'five'])
|
||||||
|
|
||||||
|
call prop_type_add('prop', #{highlight: 'Error'})
|
||||||
|
let g:long_text = repeat('x', &columns * 2)
|
||||||
|
|
||||||
|
let g:prop_id = v:null
|
||||||
|
func! Update()
|
||||||
|
if line('.') == 1
|
||||||
|
if g:prop_id == v:null
|
||||||
|
let g:prop_id = prop_add(1, 0, #{type: 'prop', text_wrap: 'wrap', text: g:long_text})
|
||||||
|
endif
|
||||||
|
elseif g:prop_id != v:null
|
||||||
|
call prop_remove(#{id: g:prop_id})
|
||||||
|
let g:prop_id = v:null
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
autocmd CursorMoved * call Update()
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XscriptPropsCursorMovec')
|
||||||
|
let buf = RunVimInTerminal('-S XscriptPropsCursorMovec', #{rows: 8, cols: 60})
|
||||||
|
call term_sendkeys(buf, "gg0w")
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_with_text_cursormoved_1', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "j")
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_with_text_cursormoved_2', {})
|
||||||
|
|
||||||
|
" back to the first state
|
||||||
|
call term_sendkeys(buf, "k")
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_with_text_cursormoved_1', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('XscriptPropsCursorMovec')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_props_with_text_after_split_join()
|
func Test_props_with_text_after_split_join()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
@@ -310,6 +310,7 @@ prop_add_one(
|
|||||||
buf->b_ml.ml_flags |= ML_LINE_DIRTY;
|
buf->b_ml.ml_flags |= ML_LINE_DIRTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changed_line_display_buf(buf);
|
||||||
changed_lines_buf(buf, start_lnum, end_lnum + 1, 0);
|
changed_lines_buf(buf, start_lnum, end_lnum + 1, 0);
|
||||||
res = OK;
|
res = OK;
|
||||||
|
|
||||||
@@ -1507,6 +1508,7 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
if (first_changed > 0)
|
if (first_changed > 0)
|
||||||
{
|
{
|
||||||
|
changed_line_display_buf(buf);
|
||||||
changed_lines_buf(buf, first_changed, last_changed + 1, 0);
|
changed_lines_buf(buf, first_changed, last_changed + 1, 0);
|
||||||
redraw_buf_later(buf, VALID);
|
redraw_buf_later(buf, VALID);
|
||||||
}
|
}
|
||||||
|
@@ -735,6 +735,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
194,
|
||||||
/**/
|
/**/
|
||||||
193,
|
193,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user