From ba24cfe9125eda97346e3ceee42686fb9f46046f Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Sat, 11 Feb 2023 14:20:49 +0100 Subject: Delete snippet placeholders when accepting completion When accepting a snippet completion we automatically delete the placeholders for now as doing so manual is quite cumbersome. In the future we should keep these as a mark + virtual text that is automatically removed once the cursor moves there. --- helix-lsp/src/snippet.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'helix-lsp/src') diff --git a/helix-lsp/src/snippet.rs b/helix-lsp/src/snippet.rs index 87c839f9..441c419f 100644 --- a/helix-lsp/src/snippet.rs +++ b/helix-lsp/src/snippet.rs @@ -64,6 +64,7 @@ pub fn into_transaction<'a>( edit: &lsp_types::TextEdit, line_ending: &str, offset_encoding: OffsetEncoding, + include_placeholer: bool, ) -> helix_core::Transaction { use helix_core::{smallvec, Range, Selection, Transaction}; use SnippetElement::*; @@ -119,10 +120,14 @@ pub fn into_transaction<'a>( // https://doc.rust-lang.org/beta/unstable-book/language-features/box-patterns.html // would make this a bit nicer Text(text) => { - let len_chars = text.chars().count(); - tabstops.push((tabstop, Range::new(offset, offset + len_chars + 1))); - offset += len_chars; - insert.push_str(text); + if include_placeholer { + let len_chars = text.chars().count(); + tabstops.push((tabstop, Range::new(offset, offset + len_chars + 1))); + offset += len_chars; + insert.push_str(text); + } else { + tabstops.push((tabstop, Range::point(offset))); + } } other => { log::error!( -- cgit v1.2.3-70-g09d2