mirror of
https://github.com/neovim/neovim
synced 2025-07-20 13:22:26 +00:00
fix(buffer_updates): handle :sort of already sorted buffer
This commit is contained in:
@ -702,11 +702,11 @@ void ex_sort(exarg_T *eap)
|
|||||||
mark_adjust(eap->line2, MAXLNUM, -deleted, 0L, kExtmarkNOOP);
|
mark_adjust(eap->line2, MAXLNUM, -deleted, 0L, kExtmarkNOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (change_occurred || deleted != 0) {
|
||||||
extmark_splice(curbuf, eap->line1-1, 0,
|
extmark_splice(curbuf, eap->line1-1, 0,
|
||||||
count, 0, old_count,
|
count, 0, old_count,
|
||||||
lnum - eap->line2, 0, new_count, kExtmarkUndo);
|
lnum - eap->line2, 0, new_count, kExtmarkUndo);
|
||||||
|
|
||||||
if (change_occurred || deleted != 0) {
|
|
||||||
changed_lines(eap->line1, 0, eap->line2 + 1, -deleted, true);
|
changed_lines(eap->line1, 0, eap->line2 + 1, -deleted, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1088,6 +1088,22 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it(":sort lines", function()
|
||||||
|
local check_events = setup_eventcheck(verify, {"CCC", "BBB", "AAA"})
|
||||||
|
|
||||||
|
command "%sort"
|
||||||
|
check_events {
|
||||||
|
{ "test1", "bytes", 1, 3, 0, 0, 0, 3, 0, 12, 3, 0, 12 };
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("handles already sorted lines", function()
|
||||||
|
local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
|
||||||
|
|
||||||
|
command "%sort"
|
||||||
|
check_events { }
|
||||||
|
end)
|
||||||
|
|
||||||
local function test_lockmarks(mode)
|
local function test_lockmarks(mode)
|
||||||
local description = (mode ~= "") and mode or "(baseline)"
|
local description = (mode ~= "") and mode or "(baseline)"
|
||||||
it("test_lockmarks " .. description .. " %delete _", function()
|
it("test_lockmarks " .. description .. " %delete _", function()
|
||||||
|
Reference in New Issue
Block a user