on master help sign in
indent snippets to line indent instead of completion start (#6263)
171d28dPascal Kuthe
helix-lsp/src/lib.rs+6−10
@@ -345,6 +345,7 @@ pub mod util {
345 line_ending: &str,
345 line_ending: &str,
346 include_placeholder: bool,
346 include_placeholder: bool,
347 tab_width: usize,
347 tab_width: usize,
348+ indent_width: usize,
348 ) -> Transaction {
349 ) -> Transaction {
349 let text = doc.slice(..);
350 let text = doc.slice(..);
350
351
@@ -374,19 +375,14 @@ pub mod util {
374 let mapped_replacement_end = (replacement_end as i128 + off) as usize;
375 let mapped_replacement_end = (replacement_end as i128 + off) as usize;
375
376
376 let line_idx = mapped_doc.char_to_line(mapped_replacement_start);
377 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+ let indent_level = helix_core::indent::indent_level_for_line(
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(
383 mapped_doc.line(line_idx),
379 mapped_doc.line(line_idx),
384− pos_on_line,
385 tab_width,
380 tab_width,
386− )
381+ indent_width,
387− .col;
382+ ) * indent_width;
383+
388 let newline_with_offset = format!(
384 let newline_with_offset = format!(
389− "{line_ending}{blank:width$}",
385+ "{line_ending}{blank:indent_level$}",
390 line_ending = line_ending,
386 line_ending = line_ending,
391 blank = ""
387 blank = ""
392 );
388 );
helix-term/src/ui/completion.rs+1
@@ -182,6 +182,7 @@ impl Completion {
182 doc.line_ending.as_str(),
182 doc.line_ending.as_str(),
183 include_placeholder,
183 include_placeholder,
184 doc.tab_width(),
184 doc.tab_width(),
185+ doc.indent_width(),
185 ),
186 ),
186 Err(err) => {
187 Err(err) => {
187 log::error!(
188 log::error!(