Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ruby_lsp/requests/on_type_formatting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def add_edit_with_text(text, position = @position)

#: (Integer line, Integer character) -> void
def move_cursor_to(line, character)
return unless /Visual Studio Code|Cursor/.match?(@client_name)
return unless /Visual Studio Code|Cursor|VSCodium/.match?(@client_name)

position = Interface::Position.new(
line: line,
Expand Down
40 changes: 40 additions & 0 deletions test/requests/on_type_formatting_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,46 @@ def test_includes_snippets_on_cursor
assert_equal(expected_edits.to_json, T.must(edits).to_json)
end

def test_includes_snippets_on_vscodium
document = RubyLsp::RubyDocument.new(
source: +"",
version: 1,
uri: URI("file:///fake.rb"),
global_state: @global_state,
)

document.push_edits(
[{
range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
text: "class Foo",
}],
version: 2,
)
document.parse!

edits = RubyLsp::Requests::OnTypeFormatting.new(
document,
{ line: 1, character: 2 },
"\n",
"VSCodium",
).perform
expected_edits = [
{
range: { start: { line: 1, character: 2 }, end: { line: 1, character: 2 } },
newText: "\n",
},
{
range: { start: { line: 1, character: 2 }, end: { line: 1, character: 2 } },
newText: "end",
},
{
range: { start: { line: 1, character: 2 }, end: { line: 1, character: 2 } },
newText: "$0",
},
]
assert_equal(expected_edits.to_json, T.must(edits).to_json)
end

def test_does_not_confuse_class_parameter_with_keyword
document = RubyLsp::RubyDocument.new(
source: +"",
Expand Down
Loading