aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorRyan Fowler2023-07-21 22:21:21 +0000
committerGitHub2023-07-21 22:21:21 +0000
commit5c41f22c2a20a1b8a91ddd6397686bd752591ffc (patch)
treef64c0dba72fb6b14a7c0f0f4c98220a25f5b2462 /helix-view
parent8977123f25baba838d2d16f8a40e78563c4ebf4a (diff)
Add support for LSP DidChangeWatchedFiles (#7665)
* Add initial support for LSP DidChangeWatchedFiles * Move file event Handler to helix-lsp * Simplify file event handling * Refactor file event handling * Block on future within LSP file event handler * Fully qualify uses of the file_event::Handler type * Rename ops field to options * Revert newline removal from helix-view/Cargo.toml * Ensure file event Handler is cleaned up when lsp client is shutdown
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/editor.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index affe87dd..20469ae9 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -1535,7 +1535,18 @@ impl Editor {
let path = path.map(|path| path.into());
let doc = doc_mut!(self, &doc_id);
- let future = doc.save(path, force)?;
+ let doc_save_future = doc.save(path, force)?;
+
+ // When a file is written to, notify the file event handler.
+ // Note: This can be removed once proper file watching is implemented.
+ let handler = self.language_servers.file_event_handler.clone();
+ let future = async move {
+ let res = doc_save_future.await;
+ if let Ok(event) = &res {
+ handler.file_changed(event.path.clone());
+ }
+ res
+ };
use futures_util::stream;
@@ -1671,6 +1682,14 @@ impl Editor {
&self,
timeout: Option<u64>,
) -> Result<(), tokio::time::error::Elapsed> {
+ // Remove all language servers from the file event handler.
+ // Note: this is non-blocking.
+ for client in self.language_servers.iter_clients() {
+ self.language_servers
+ .file_event_handler
+ .remove_client(client.id());
+ }
+
tokio::time::timeout(
Duration::from_millis(timeout.unwrap_or(3000)),
future::join_all(