From 9c558fc4705934097b5f20b100462fc1fa4f50e1 Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Wed, 5 Apr 2023 01:38:17 +0200 Subject: ensure correct trigger/start completion offset When re requesting a completion that already has a selected item we reuse that selections savepoint. However, the selection has likely changed since that savepoint which requires us to use the selection from that savepoint --- helix-view/src/document.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'helix-view') diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 4948befd..e467efd3 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -114,6 +114,19 @@ pub struct SavePoint { /// The view this savepoint is associated with pub view: ViewId, revert: Mutex, + pub text: Rope, +} + +impl SavePoint { + pub fn cursor(&self) -> usize { + // we always create transactions with selections + self.revert + .lock() + .selection() + .unwrap() + .primary() + .cursor(self.text.slice(..)) + } } pub struct Document { @@ -1230,6 +1243,7 @@ impl Document { let savepoint = Arc::new(SavePoint { view: view.id, revert: Mutex::new(revert), + text: self.text.clone(), }); self.savepoints.push(Arc::downgrade(&savepoint)); savepoint -- cgit v1.2.3-70-g09d2