From 0a3bf4f74534b2e438bf20ef91c7677b219cfac8 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 24 Nov 2023 15:23:43 -0500 Subject: [PATCH] Remove comment continuation anchor (#1215) The anchor is only necessary if we need to move the cursor to a different position than the one where the edit finishes. This is never the case for comment continuation --- lib/ruby_lsp/requests/on_type_formatting.rb | 1 - test/requests/on_type_formatting_test.rb | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib/ruby_lsp/requests/on_type_formatting.rb b/lib/ruby_lsp/requests/on_type_formatting.rb index 65ea034eb..833bd5635 100644 --- a/lib/ruby_lsp/requests/on_type_formatting.rb +++ b/lib/ruby_lsp/requests/on_type_formatting.rb @@ -139,7 +139,6 @@ def handle_heredoc_end(delimiter) sig { params(spaces: String).void } def handle_comment_line(spaces) add_edit_with_text("##{spaces}") - move_cursor_to(@position[:line], @indentation + spaces.size + 1) end sig { params(text: String, position: Document::PositionShape).void } diff --git a/test/requests/on_type_formatting_test.rb b/test/requests/on_type_formatting_test.rb index 73f3145c2..89ed5acd9 100644 --- a/test/requests/on_type_formatting_test.rb +++ b/test/requests/on_type_formatting_test.rb @@ -209,10 +209,6 @@ def test_comment_continuation range: { start: { line: 0, character: 14 }, end: { line: 0, character: 14 } }, newText: "# ", }, - { - range: { start: { line: 0, character: 9 }, end: { line: 0, character: 9 } }, - newText: "$0", - }, ] assert_equal(expected_edits.to_json, T.must(edits).to_json) end @@ -253,10 +249,6 @@ def test_comment_continuation_with_other_line_break_matches range: { start: { line: 0, character: 14 }, end: { line: 0, character: 14 } }, newText: "# ", }, - { - range: { start: { line: 0, character: 9 }, end: { line: 0, character: 9 } }, - newText: "$0", - }, ] assert_equal(expected_edits.to_json, T.must(edits).to_json) end @@ -282,10 +274,6 @@ def test_comment_continuation_when_inserting_new_line_in_the_middle range: { start: { line: 0, character: 7 }, end: { line: 0, character: 7 } }, newText: "# ", }, - { - range: { start: { line: 0, character: 2 }, end: { line: 0, character: 2 } }, - newText: "$0", - }, ] assert_equal(expected_edits.to_json, T.must(edits).to_json) end