mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(lsp): fix reverse sorting of same position text edits (#29212)
Problem: Text edits with the same position (both line and character) were being reverse sorted prior to being applied which differs from the lsp spec Solution: Change the sort order for just the same position edits
This commit is contained in:
@@ -391,7 +391,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
|
|||||||
return a.range.start.character > b.range.start.character
|
return a.range.start.character > b.range.start.character
|
||||||
end
|
end
|
||||||
if a._index ~= b._index then
|
if a._index ~= b._index then
|
||||||
return a._index > b._index
|
return a._index < b._index
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -1789,9 +1789,9 @@ describe('LSP', function()
|
|||||||
}
|
}
|
||||||
exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1, 'utf-16')
|
exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1, 'utf-16')
|
||||||
eq({
|
eq({
|
||||||
'',
|
'3',
|
||||||
'123',
|
'foo',
|
||||||
'fooFbar',
|
'12Fbar',
|
||||||
'123irst guy',
|
'123irst guy',
|
||||||
'baz line of text',
|
'baz line of text',
|
||||||
'The next line of text',
|
'The next line of text',
|
||||||
@@ -1813,9 +1813,9 @@ describe('LSP', function()
|
|||||||
}
|
}
|
||||||
exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1, 'utf-16')
|
exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1, 'utf-16')
|
||||||
eq({
|
eq({
|
||||||
'',
|
'3',
|
||||||
'123',
|
'foo',
|
||||||
'fooFbar',
|
'12Fbar',
|
||||||
'123irst guy',
|
'123irst guy',
|
||||||
'baz line of text',
|
'baz line of text',
|
||||||
'The next line of text',
|
'The next line of text',
|
||||||
|
Reference in New Issue
Block a user