From a5e475fcc269b32a8a487f787af20802cbfabe28 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sat, 5 Mar 2022 09:17:56 -0800 Subject: fix(lsp): start incremental sync range at previous newline character (#17610) This change forces the start of an incremental sync range to begin always on an existing line. --- .../plugin/lsp/incremental_sync_spec.lua | 33 +++++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'test/functional/plugin/lsp/incremental_sync_spec.lua') diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua index 4e3eddb960..da54f3c649 100644 --- a/test/functional/plugin/lsp/incremental_sync_spec.lua +++ b/test/functional/plugin/lsp/incremental_sync_spec.lua @@ -207,16 +207,16 @@ describe('incremental synchronization', function() { range = { ['start'] = { - character = 0, - line = 1 + character = 11, + line = 0, }, ['end'] = { character = 0, line = 1 } }, - rangeLength = 0, - text = 'hello world\n' + rangeLength = 1, + text = '\nhello world\n' } } test_edit({"hello world"}, {"yyp"}, expected_text_changes, 'utf-16', '\n') @@ -226,19 +226,38 @@ describe('incremental synchronization', function() { range = { ['start'] = { + character = 11, + line = 0 + }, + ['end'] = { character = 0, line = 1 + } + }, + rangeLength = 1, + text = '\n\n' + } + } + test_edit({"hello world"}, {"o"}, expected_text_changes, 'utf-16', '\n') + end) + it('adding a line to an empty buffer', function() + local expected_text_changes = { + { + range = { + ['start'] = { + character = 0, + line = 0 }, ['end'] = { character = 0, line = 1 } }, - rangeLength = 0, - text = '\n' + rangeLength = 1, + text = '\n\n' } } - test_edit({"hello world"}, {"o"}, expected_text_changes, 'utf-16', '\n') + test_edit({""}, {"o"}, expected_text_changes, 'utf-16', '\n') end) end) describe('multi line edit', function() -- cgit From 3800615da9eaf9e8b26d9040c882c74084d688e4 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sun, 6 Mar 2022 07:52:11 -0800 Subject: fix(lsp): handle insertion of previous line (#17618) --- test/functional/plugin/lsp/incremental_sync_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/functional/plugin/lsp/incremental_sync_spec.lua') diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua index da54f3c649..4985da9cd7 100644 --- a/test/functional/plugin/lsp/incremental_sync_spec.lua +++ b/test/functional/plugin/lsp/incremental_sync_spec.lua @@ -259,6 +259,25 @@ describe('incremental synchronization', function() } test_edit({""}, {"o"}, expected_text_changes, 'utf-16', '\n') end) + it('insert a line above the current line', function() + local expected_text_changes = { + { + range = { + ['start'] = { + character = 0, + line = 0 + }, + ['end'] = { + character = 0, + line = 0 + } + }, + rangeLength = 0, + text = '\n' + } + } + test_edit({""}, {"O"}, expected_text_changes, 'utf-16', '\n') + end) end) describe('multi line edit', function() it('deletion and insertion', function() -- cgit