clarify comments about completion savepoints

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
Pascal Kuthe 2023-04-07 14:50:47 +02:00 committed by Blaž Hrastnik
parent 28b730381c
commit 6842fd4c36
3 changed files with 9 additions and 9 deletions

View File

@ -226,14 +226,14 @@ fn completion_changes(transaction: &Transaction, trigger_offset: usize) -> Vec<C
match event { match event {
PromptEvent::Abort => {} PromptEvent::Abort => {}
PromptEvent::Update => { PromptEvent::Update => {
// Update creates "ghost" transactiosn which are not send to the // Update creates "ghost" transactions which are not sent to the
// lsp server to avoid messing up rerequesting completions. Once a // lsp server to avoid messing up re-requesting completions. Once a
// completion has been selected (with) tab it's always accepted whenever anything // completion has been selected (with tab, c-n or c-p) it's always accepted whenever anything
// is typed. The only way to avoid that is to explicitly abort the completion // is typed. The only way to avoid that is to explicitly abort the completion
// with esc/c-c. This will remove the "ghost" transaction. // with c-c. This will remove the "ghost" transaction.
// //
// The ghost transaction is modeled with a transaction that is not send to the LS. // The ghost transaction is modeled with a transaction that is not sent to the LS.
// (apply_temporary) and a savepoint. It's extremly important this savepoint is restored // (apply_temporary) and a savepoint. It's extremely important this savepoint is restored
// (also without sending the transaction to the LS) *before any further transaction is applied*. // (also without sending the transaction to the LS) *before any further transaction is applied*.
// Otherwise incremental sync breaks (since the state of the LS doesn't match the state the transaction // Otherwise incremental sync breaks (since the state of the LS doesn't match the state the transaction
// is applied to). // is applied to).
@ -293,7 +293,7 @@ fn completion_changes(transaction: &Transaction, trigger_offset: usize) -> Vec<C
changes: completion_changes(&transaction, trigger_offset), changes: completion_changes(&transaction, trigger_offset),
}); });
// TOOD: add additional _edits to completion_changes? // TODO: add additional _edits to completion_changes?
if let Some(additional_edits) = item.item.additional_text_edits { if let Some(additional_edits) = item.item.additional_text_edits {
if !additional_edits.is_empty() { if !additional_edits.is_empty() {
let transaction = util::generate_transaction_from_edits( let transaction = util::generate_transaction_from_edits(

View File

@ -1197,7 +1197,7 @@ pub fn apply(&mut self, transaction: &Transaction, view_id: ViewId) -> bool {
self.apply_inner(transaction, view_id, true) self.apply_inner(transaction, view_id, true)
} }
/// Apply a [`Transaction`] to the [`Document`] to change its text. /// Apply a [`Transaction`] to the [`Document`] to change its text
/// without notifying the language servers. This is useful for temporary transactions /// without notifying the language servers. This is useful for temporary transactions
/// that must not influence the server. /// that must not influence the server.
pub fn apply_temporary(&mut self, transaction: &Transaction, view_id: ViewId) -> bool { pub fn apply_temporary(&mut self, transaction: &Transaction, view_id: ViewId) -> bool {

View File

@ -911,7 +911,7 @@ pub enum CompleteAction {
trigger_offset: usize, trigger_offset: usize,
changes: Vec<Change>, changes: Vec<Change>,
}, },
/// A savepoint of the currently active completion. The completion /// A savepoint of the currently selected completion. The savepoint
/// MUST be restored before sending any event to the LSP /// MUST be restored before sending any event to the LSP
Selected { savepoint: Arc<SavePoint> }, Selected { savepoint: Arc<SavePoint> },
} }