aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 0f1f3a8f..59a1c42c 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -13,8 +13,8 @@ use helix_core::{
history::History,
line_ending::auto_detect_line_ending,
syntax::{self, LanguageConfiguration},
- ChangeSet, Diagnostic, LineEnding, Rope, RopeBuilder, Selection, State, Syntax, Transaction,
- DEFAULT_LINE_ENDING,
+ ChangeSet, Diagnostic, LineEnding, Rope, RopeBuilder, RopeSlice, Selection, State, Syntax,
+ Transaction, DEFAULT_LINE_ENDING,
};
use helix_lsp::util::LspFormatting;
@@ -1000,6 +1000,22 @@ impl Document {
&self.selections[&view_id]
}
+ #[inline]
+ pub fn selection_mut(&mut self, view_id: ViewId) -> &mut Selection {
+ self.selections
+ .get_mut(&view_id)
+ .expect("No selection set with the given ViewId")
+ }
+
+ pub fn text_and_mut_selection(&mut self, view_id: ViewId) -> (RopeSlice, &mut Selection) {
+ (
+ self.text.slice(..),
+ self.selections
+ .get_mut(&view_id)
+ .expect("No selection set with the given ViewId"),
+ )
+ }
+
pub fn relative_path(&self) -> Option<PathBuf> {
let cwdir = std::env::current_dir().expect("couldn't determine current directory");