Skip to content

Commit

Permalink
Use cached code units in range formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Oct 10, 2024
1 parent 86925ea commit 9e47368
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ruby_lsp/requests/range_formatting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ def perform
)
return unless formatted_text

code_units_cache = @document.code_units_cache

[
Interface::TextEdit.new(
range: Interface::Range.new(
start: Interface::Position.new(
line: location.start_line - 1,
character: location.start_code_units_column(@document.encoding),
character: location.cached_start_code_units_column(code_units_cache),
),
end: Interface::Position.new(
line: location.end_line - 1,
character: location.end_code_units_column(@document.encoding),
character: location.cached_end_code_units_column(code_units_cache),
),
),
new_text: formatted_text.strip,
Expand Down

0 comments on commit 9e47368

Please sign in to comment.