on master help sign in
indent snippets to line indent instead of completion start (#6263)
commit171d28d2bdefa59ebada9eee13ef7e5cbdf0c0af authorPascal Kuthe <pascal.kuthe@semimod.de> dateSat 11 Mar 2023, 03:34 (4 years ago) parentbdcd4d9
2 files changed+7−10
helix-lsp/src/lib.rs+6−10 helix-term/src/ui/completion.rs+1
helix-lsp/src/lib.rs+6−10
@@ -345,6 +345,7 @@ pub mod util {
345345 line_ending: &str,
346346 include_placeholder: bool,
347347 tab_width: usize,
348+ indent_width: usize,
348349 ) -> Transaction {
349350 let text = doc.slice(..);
350351
@@ -374,19 +375,14 @@ pub mod util {
374375 let mapped_replacement_end = (replacement_end as i128 + off) as usize;
375376
376377 let line_idx = mapped_doc.char_to_line(mapped_replacement_start);
377− let pos_on_line = mapped_replacement_start - mapped_doc.line_to_char(line_idx);
378−
379− // we only care about the actual offset here (not virtual text/softwrap)
380− // so it's ok to use the deprecated function here
381− #[allow(deprecated)]
382− let width = helix_core::visual_coords_at_pos(
378+ let indent_level = helix_core::indent::indent_level_for_line(
383379 mapped_doc.line(line_idx),
384− pos_on_line,
385380 tab_width,
386− )
387− .col;
381+ indent_width,
382+ ) * indent_width;
383+
388384 let newline_with_offset = format!(
389− "{line_ending}{blank:width$}",
385+ "{line_ending}{blank:indent_level$}",
390386 line_ending = line_ending,
391387 blank = ""
392388 );
helix-term/src/ui/completion.rs+1
@@ -182,6 +182,7 @@ impl Completion {
182182 doc.line_ending.as_str(),
183183 include_placeholder,
184184 doc.tab_width(),
185+ doc.indent_width(),
185186 ),
186187 Err(err) => {
187188 log::error!(