aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-29 07:32:42 +0000
committerBlaž Hrastnik2021-03-29 07:32:42 +0000
commit742b3a709fd7680d77bcda5ae08f2a9539b6a20e (patch)
tree38589e2b87ea31ee879bc48da3c5381830ad7e5c /helix-view/src
parent0083a6c325d5bb9dc33a43e5b3d727bde0d7990b (diff)
Store intra-files jumps (goto) on the jumplist.
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs5
-rw-r--r--helix-view/src/view.rs9
2 files changed, 11 insertions, 3 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index abc829c0..6e73104a 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -275,6 +275,11 @@ impl Document {
}
#[inline]
+ pub fn id(&self) -> DocumentId {
+ self.id
+ }
+
+ #[inline]
pub fn mode(&self) -> Mode {
self.mode
}
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 7a239d4a..9e4c1373 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -27,9 +27,12 @@ impl JumpList {
}
pub fn push(&mut self, jump: Jump) {
- self.jumps.truncate(self.current + 1);
- self.jumps.push(jump);
- self.current += 1;
+ self.jumps.truncate(self.current);
+ // don't push duplicates
+ if self.jumps.last() != Some(&jump) {
+ self.jumps.push(jump);
+ self.current = self.jumps.len();
+ }
}
pub fn forward(&mut self, count: usize) -> Option<&Jump> {