diff --git a/lib/ruby_lsp/requests/on_type_formatting.rb b/lib/ruby_lsp/requests/on_type_formatting.rb index e9a1a802a..92b6717ad 100644 --- a/lib/ruby_lsp/requests/on_type_formatting.rb +++ b/lib/ruby_lsp/requests/on_type_formatting.rb @@ -190,7 +190,7 @@ def auto_indent_after_end_keyword add_edit_with_text(" ", { line: i, character: 0 }) end - move_cursor_to(@position[:line] - 1, 3) + move_cursor_to(@position[:line], @position[:character]) add_edit_with_text("\n" + (" " * (start_line_indentation + 2)), @position) end diff --git a/test/requests/on_type_formatting_test.rb b/test/requests/on_type_formatting_test.rb index 4a36c69e5..984272eea 100644 --- a/test/requests/on_type_formatting_test.rb +++ b/test/requests/on_type_formatting_test.rb @@ -384,7 +384,7 @@ def test_auto_indent_after_end_keyword newText: " ", }, { - range: { start: { line: 2, character: 3 }, end: { line: 2, character: 3 } }, + range: { start: { line: 3, character: 0 }, end: { line: 3, character: 0 } }, newText: "$0", }, {