aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-09-02 02:28:40 +0000
committerBlaž Hrastnik2021-09-06 06:25:46 +0000
commitdc7799b980826ffe33ed635968def79daf20bd10 (patch)
tree2011ba44c63b981a5cad3aebacc0aa467337c70c /helix-view
parent63e191ea3b2ce116c39a446b8fab10a360fd8a33 (diff)
lsp: Refactor code that could use document_by_path_mut
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/editor.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 050f2645..0d914e45 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -340,6 +340,11 @@ impl Editor {
.find(|doc| doc.path().map(|p| p == path.as_ref()).unwrap_or(false))
}
+ pub fn document_by_path_mut<P: AsRef<Path>>(&mut self, path: P) -> Option<&mut Document> {
+ self.documents_mut()
+ .find(|doc| doc.path().map(|p| p == path.as_ref()).unwrap_or(false))
+ }
+
pub fn cursor(&self) -> (Option<Position>, CursorKind) {
let view = view!(self);
let doc = &self.documents[view.doc];