diff options
author | Pascal Kuthe | 2023-04-04 23:38:17 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2023-05-18 06:16:50 +0000 |
commit | 9c558fc4705934097b5f20b100462fc1fa4f50e1 (patch) | |
tree | 75271bddb0add9c78fa25fcc0a71399a98da13b2 /helix-view | |
parent | 30ff7f8db29d5fc84191268b94ec971e7ca5da5d (diff) |
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
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/document.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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<Transaction>, + 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 |