diff options
author | Gokul Soumya | 2021-08-12 07:00:42 +0000 |
---|---|---|
committer | GitHub | 2021-08-12 07:00:42 +0000 |
commit | d84f8b5fdef71da87ee108db07ba1167fc6a769b (patch) | |
tree | 057f87cb1107aae3eb966ff3e228b15d3e36ff2e /helix-view/src/document.rs | |
parent | 7d51805e94a461834ce34e0829da5859d1f9db32 (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/document.rs')
-rw-r--r-- | helix-view/src/document.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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<Self, Error> { 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<ViewId, Selection> { + &self.selections + } + pub fn relative_path(&self) -> Option<PathBuf> { let cwdir = std::env::current_dir().expect("couldn't determine current directory"); |