aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorGokul Soumya2021-08-12 07:00:42 +0000
committerGitHub2021-08-12 07:00:42 +0000
commitd84f8b5fdef71da87ee108db07ba1167fc6a769b (patch)
tree057f87cb1107aae3eb966ff3e228b15d3e36ff2e /helix-view/src/editor.rs
parent7d51805e94a461834ce34e0829da5859d1f9db32 (diff)
Show file preview in split pane in fuzzy finder (#534)
* Add preview pane for fuzzy finder * Fix picker preview lag by caching * Add picker preview for document symbols * Cache picker preview per document instead of view * Use line instead of range for preview doc * Add picker preview for buffer picker * Fix render bug and refactor picker * Refactor picker preview rendering * Split picker and preview and compose The current selected item is cloned on every event, which is undesirable * Refactor out clones in previewed picker * Retrieve doc from editor if possible in filepicker * Disable syntax highlight for picker preview Files already loaded in memory have syntax highlighting enabled * Ignore directory symlinks in file picker * Cleanup unnecessary pubs and derives * Remove unnecessary highlight from file picker * Reorganize buffer rendering * Use normal picker for code actions * Remove unnecessary generics and trait impls * Remove prepare_for_render and make render mutable * Skip picker preview if screen small, less padding
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 9b7f8429..413b7913 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -7,7 +7,11 @@ use crate::{
};
use futures_util::future;
-use std::{path::PathBuf, sync::Arc, time::Duration};
+use std::{
+ path::{Path, PathBuf},
+ sync::Arc,
+ time::Duration,
+};
use slotmap::SlotMap;
@@ -222,7 +226,7 @@ impl Editor {
let id = if let Some(id) = id {
id
} else {
- let mut doc = Document::open(path, None, Some(&self.theme), Some(&self.syn_loader))?;
+ let mut doc = Document::open(&path, None, Some(&self.theme), Some(&self.syn_loader))?;
// try to find a language server based on the language name
let language_server = doc
@@ -316,6 +320,11 @@ impl Editor {
self.documents.iter_mut().map(|(_id, doc)| doc)
}
+ pub fn document_by_path<P: AsRef<Path>>(&self, path: P) -> Option<&Document> {
+ self.documents()
+ .find(|doc| doc.path().map(|p| p == path.as_ref()).unwrap_or(false))
+ }
+
// pub fn current_document(&self) -> Document {
// let id = self.view().doc;
// let doc = &mut editor.documents[id];