Skip to content

Commit

Permalink
resolve completions before applying transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalkuthe committed Apr 4, 2023
1 parent 45b1eba commit a3a4645
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ impl Completion {
// always present here
let item = item.unwrap();

// apply additional edits, mostly used to auto import unqualified types
let resolved_item = if item
.additional_text_edits
.as_ref()
.map(|edits| !edits.is_empty())
.unwrap_or(false)
{
None
} else {
Self::resolve_completion_item(doc, item.clone())
};

// if more text was entered, remove it
doc.restore(view, &savepoint, true);
Expand All @@ -276,17 +287,6 @@ impl Completion {
changes: completion_changes(&transaction, trigger_offset),
});

// apply additional edits, mostly used to auto import unqualified types
let resolved_item = if item
.additional_text_edits
.as_ref()
.map(|edits| !edits.is_empty())
.unwrap_or(false)
{
None
} else {
Self::resolve_completion_item(doc, item.clone())
};
if let Some(additional_edits) = resolved_item
.as_ref()
.and_then(|item| item.additional_text_edits.as_ref())
Expand Down

0 comments on commit a3a4645

Please sign in to comment.