mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-12-23 09:19:21 +00:00
Create file watcher on main thread
This commit is contained in:
parent
888fb2f0d8
commit
3eec105cc4
1 changed files with 11 additions and 16 deletions
|
|
@ -36,7 +36,6 @@ use crate::{
|
|||
enum InternalMessage {
|
||||
SetDistro(Distribution),
|
||||
SetOptions(Arc<Options>),
|
||||
FileWatcher(notify::RecommendedWatcher),
|
||||
FileEvent(notify::Event),
|
||||
}
|
||||
|
||||
|
|
@ -166,28 +165,27 @@ impl Server {
|
|||
}
|
||||
|
||||
self.register_diagnostics_handler();
|
||||
self.register_file_watching();
|
||||
|
||||
self.spawn(move |server| {
|
||||
server.register_config_capability();
|
||||
server.register_file_watching();
|
||||
let _ = server.pull_config();
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn register_file_watching(&self) {
|
||||
fn register_file_watching(&mut self) {
|
||||
let tx = self.internal_tx.clone();
|
||||
self.internal_tx
|
||||
.send(InternalMessage::FileWatcher(
|
||||
notify::recommended_watcher(move |ev: Result<notify::Event, notify::Error>| {
|
||||
if let Ok(ev) = ev {
|
||||
tx.send(InternalMessage::FileEvent(ev)).unwrap();
|
||||
}
|
||||
})
|
||||
.unwrap(),
|
||||
))
|
||||
.unwrap();
|
||||
let watcher = notify::recommended_watcher(move |ev: Result<_, _>| {
|
||||
if let Ok(ev) = ev {
|
||||
let _ = tx.send(InternalMessage::FileEvent(ev));
|
||||
}
|
||||
});
|
||||
|
||||
if let Ok(watcher) = watcher {
|
||||
self.workspace.register_watcher(watcher);
|
||||
}
|
||||
}
|
||||
|
||||
fn register_config_capability(&self) {
|
||||
|
|
@ -793,9 +791,6 @@ impl Server {
|
|||
self.workspace.environment.options = options;
|
||||
self.reparse_all()?;
|
||||
}
|
||||
InternalMessage::FileWatcher(watcher) => {
|
||||
self.workspace.register_watcher(watcher);
|
||||
}
|
||||
InternalMessage::FileEvent(ev) => {
|
||||
match ev.kind {
|
||||
notify::EventKind::Create(_) | notify::EventKind::Modify(_) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue