Merge pull request #14757 from jbyuki/open_line_changed_bytes

fix: changed byte ranges for indented lines
This commit is contained in:
Björn Linse
2021-06-09 23:49:02 +02:00
committed by GitHub
2 changed files with 8 additions and 6 deletions

View File

@@ -1695,10 +1695,12 @@ int open_line(
int new_len = (int)STRLEN(saved_line);
// TODO(vigoux): maybe there is issues there with expandtabs ?
int cols_spliced = 0;
if (new_len < curwin->w_cursor.col) {
extmark_splice_cols(
curbuf, (int)curwin->w_cursor.lnum,
curbuf, (int)curwin->w_cursor.lnum - 1,
new_len, curwin->w_cursor.col - new_len, 0, kExtmarkUndo);
cols_spliced = curwin->w_cursor.col - new_len;
}
saved_line = NULL;
@@ -1716,7 +1718,7 @@ int open_line(
// Always move extmarks - Here we move only the line where the
// cursor is, the previous mark_adjust takes care of the lines after
int cols_added = mincol-1+less_cols_off-less_cols;
extmark_splice(curbuf, (int)lnum-1, mincol-1,
extmark_splice(curbuf, (int)lnum-1, mincol-1 - cols_spliced,
0, less_cols_off, less_cols_off,
1, cols_added, 1 + cols_added, kExtmarkUndo);
} else {

View File

@@ -401,8 +401,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
feed '<cr>'
check_events {
{ "test1", "bytes", 1, 4, 8, 0, 115, 0, 4, 4, 0, 0, 0 };
{ "test1", "bytes", 1, 5, 7, 4, 118, 0, 0, 0, 1, 4, 5 };
{ "test1", "bytes", 1, 4, 7, 0, 114, 0, 4, 4, 0, 0, 0 };
{ "test1", "bytes", 1, 5, 7, 0, 114, 0, 0, 0, 1, 4, 5 };
}
end)
@@ -447,8 +447,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
feed '<CR>'
check_events {
{ "test1", "bytes", 1, 6, 2, 2, 16, 0, 1, 1, 0, 0, 0 };
{ "test1", "bytes", 1, 7, 1, 3, 14, 0, 0, 0, 1, 3, 4 };
{ "test1", "bytes", 1, 6, 1, 2, 13, 0, 1, 1, 0, 0, 0 };
{ "test1", "bytes", 1, 7, 1, 2, 13, 0, 0, 0, 1, 3, 4 };
}
end)