aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorMatouš Dzivjak2022-01-06 02:12:02 +0000
committerGitHub2022-01-06 02:12:02 +0000
commit2e02a1d6bc004212033b9c4e5ed0de0fd880796c (patch)
treee73a695e58ddf7242d3cab282b93dd1ad9488ee5 /helix-view/src
parent66afbc9fff1ec5947ea5718f7817887aa0c853c8 (diff)
feat(commands): shrink_selection (#1340)
* feat(commands): shrink_selection Add `shrink_selection` command that can be used to shrink previously expanded selection. To make `shrink_selection` work it was necessary to add selection history to the Document since we want to shrink the selection towards the syntax tree node that was initially selected. Selection history is cleared any time the user changes selection other way than by `expand_selection`. This ensures that we don't get some funky edge cases when user calls `shrink_selection`. Related: https://github.com/helix-editor/helix/discussions/1328 * Refactor shrink_selection, move history to view * Remove useless comment * Add default key mapping for extend&shrink selection * Rework contains_selection method * Shrink selection without expand selects first child
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/view.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 94d67acd..89a6c196 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -80,6 +80,8 @@ pub struct View {
// uses two docs because we want to be able to swap between the
// two last modified docs which we need to manually keep track of
pub last_modified_docs: [Option<DocumentId>; 2],
+ /// used to store previous selections of tree-sitter objecs
+ pub object_selections: Vec<Selection>,
}
impl View {
@@ -92,6 +94,7 @@ impl View {
jumps: JumpList::new((doc, Selection::point(0))), // TODO: use actual sel
last_accessed_doc: None,
last_modified_docs: [None, None],
+ object_selections: Vec::new(),
}
}