From 9e47368ef740afcb1a80d3559b2d9d1aa4912058 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Thu, 10 Oct 2024 11:31:51 -0400 Subject: [PATCH] Use cached code units in range formatting --- lib/ruby_lsp/requests/range_formatting.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ruby_lsp/requests/range_formatting.rb b/lib/ruby_lsp/requests/range_formatting.rb index 63705d4f8..74935dcc0 100644 --- a/lib/ruby_lsp/requests/range_formatting.rb +++ b/lib/ruby_lsp/requests/range_formatting.rb @@ -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,