From d84f8b5fdef71da87ee108db07ba1167fc6a769b Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Thu, 12 Aug 2021 12:30:42 +0530 Subject: 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--- helix-view/src/document.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'helix-view/src/document.rs') diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 99faebec..8730bef2 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -432,14 +432,14 @@ impl Document { /// Create a new document from `path`. Encoding is auto-detected, but it can be manually /// overwritten with the `encoding` parameter. pub fn open( - path: PathBuf, + path: &Path, encoding: Option<&'static encoding_rs::Encoding>, theme: Option<&Theme>, config_loader: Option<&syntax::Loader>, ) -> Result { let (rope, encoding) = if path.exists() { let mut file = - std::fs::File::open(&path).context(format!("unable to open {:?}", path))?; + std::fs::File::open(path).context(format!("unable to open {:?}", path))?; from_reader(&mut file, encoding)? } else { let encoding = encoding.unwrap_or(encoding_rs::UTF_8); @@ -449,7 +449,7 @@ impl Document { let mut doc = Self::from(rope, Some(encoding)); // set the path and try detecting the language - doc.set_path(&path)?; + doc.set_path(path)?; if let Some(loader) = config_loader { doc.detect_language(theme, loader); } @@ -904,6 +904,10 @@ impl Document { &self.selections[&view_id] } + pub fn selections(&self) -> &HashMap { + &self.selections + } + pub fn relative_path(&self) -> Option { let cwdir = std::env::current_dir().expect("couldn't determine current directory"); -- cgit v1.2.3-70-g09d2