mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
Merge pull request #12646 from vigoux/ts-fix-tilde
buffer_updates: set `deleted_bytes` correctly when hitting `~` When doing bytebased update, we need to revisit this to let outer calls of ml_get_line handle the deleted part (will be more precise)
This commit is contained in:
commit
326b87feb6
@ -1876,8 +1876,10 @@ errorret:
|
|||||||
buf->b_ml.ml_line_lnum = lnum;
|
buf->b_ml.ml_line_lnum = lnum;
|
||||||
buf->b_ml.ml_flags &= ~ML_LINE_DIRTY;
|
buf->b_ml.ml_flags &= ~ML_LINE_DIRTY;
|
||||||
}
|
}
|
||||||
if (will_change)
|
if (will_change) {
|
||||||
buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS);
|
buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS);
|
||||||
|
ml_add_deleted_len_buf(buf, buf->b_ml.ml_line_ptr, -1);
|
||||||
|
}
|
||||||
|
|
||||||
return buf->b_ml.ml_line_ptr;
|
return buf->b_ml.ml_line_ptr;
|
||||||
}
|
}
|
||||||
@ -2445,14 +2447,14 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char_u *line, bool copy)
|
|||||||
if (buf->b_ml.ml_line_lnum != lnum) { // other line buffered
|
if (buf->b_ml.ml_line_lnum != lnum) { // other line buffered
|
||||||
ml_flush_line(buf); // flush it
|
ml_flush_line(buf); // flush it
|
||||||
} else if (buf->b_ml.ml_flags & ML_LINE_DIRTY) { // same line allocated
|
} else if (buf->b_ml.ml_flags & ML_LINE_DIRTY) { // same line allocated
|
||||||
ml_add_deleted_len(buf->b_ml.ml_line_ptr, -1);
|
ml_add_deleted_len_buf(buf, buf->b_ml.ml_line_ptr, -1);
|
||||||
readlen = false; // already added the length
|
readlen = false; // already added the length
|
||||||
|
|
||||||
xfree(buf->b_ml.ml_line_ptr); // free it
|
xfree(buf->b_ml.ml_line_ptr); // free it
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readlen && kv_size(buf->update_callbacks)) {
|
if (readlen && kv_size(buf->update_callbacks)) {
|
||||||
ml_add_deleted_len(ml_get_buf(buf, lnum, false), -1);
|
ml_add_deleted_len_buf(buf, ml_get_buf(buf, lnum, false), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->b_ml.ml_line_ptr = line;
|
buf->b_ml.ml_line_ptr = line;
|
||||||
@ -2539,7 +2541,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message)
|
|||||||
// Line should always have an NL char internally (represented as NUL),
|
// Line should always have an NL char internally (represented as NUL),
|
||||||
// even if 'noeol' is set.
|
// even if 'noeol' is set.
|
||||||
assert(line_size >= 1);
|
assert(line_size >= 1);
|
||||||
ml_add_deleted_len((char_u *)dp + line_start, line_size-1);
|
ml_add_deleted_len_buf(buf, (char_u *)dp + line_start, line_size-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* special case: If there is only one line in the data block it becomes empty.
|
* special case: If there is only one line in the data block it becomes empty.
|
||||||
|
@ -360,6 +360,52 @@ static int nlua_schedule(lua_State *const lstate)
|
|||||||
{8:}} |
|
{8:}} |
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
|
feed("gg$")
|
||||||
|
feed("~")
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{2:/// Schedule Lua callback on main loop's event queu^E} |
|
||||||
|
{3:static} {3:int} nlua_schedule({3:lua_State} *{3:const} lstate) |
|
||||||
|
{ |
|
||||||
|
{2:/*} |
|
||||||
|
{2: if (lua_type(lstate, 1) != LUA_TFUNCTION} |
|
||||||
|
{2: || lstate != lstate) {} |
|
||||||
|
{2: lua_pushliteral(lstate, "vim.schedule: expected function");} |
|
||||||
|
{2: return lua_error(lstate);} |
|
||||||
|
{2:*/} |
|
||||||
|
} |
|
||||||
|
|
|
||||||
|
{7:LuaRef} cb = nlua_ref(lstate, {5:1}); |
|
||||||
|
|
|
||||||
|
multiqueue_put(main_loop.events, nlua_schedule_event, |
|
||||||
|
{5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
|
||||||
|
{4:return} {5:0}; |
|
||||||
|
{8:}} |
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
|
||||||
|
|
||||||
|
feed("re")
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{2:/// Schedule Lua callback on main loop's event queu^e} |
|
||||||
|
{3:static} {3:int} nlua_schedule({3:lua_State} *{3:const} lstate) |
|
||||||
|
{ |
|
||||||
|
{2:/*} |
|
||||||
|
{2: if (lua_type(lstate, 1) != LUA_TFUNCTION} |
|
||||||
|
{2: || lstate != lstate) {} |
|
||||||
|
{2: lua_pushliteral(lstate, "vim.schedule: expected function");} |
|
||||||
|
{2: return lua_error(lstate);} |
|
||||||
|
{2:*/} |
|
||||||
|
} |
|
||||||
|
|
|
||||||
|
{7:LuaRef} cb = nlua_ref(lstate, {5:1}); |
|
||||||
|
|
|
||||||
|
multiqueue_put(main_loop.events, nlua_schedule_event, |
|
||||||
|
{5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
|
||||||
|
{4:return} {5:0}; |
|
||||||
|
{8:}} |
|
||||||
|
|
|
||||||
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('inspects language', function()
|
it('inspects language', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user