1. Fix the PathBuf value in file monitoring events in the Windows environment (#3538)

This commit is contained in:
ifengqi 2024-09-24 16:30:16 +08:00 committed by GitHub
parent b6d11b39dc
commit ea9b7a9c9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -1266,8 +1266,19 @@ fn handle_fs_events(&self, events: Vec<(WatchToken, notify::Event)>) {
}
fn handle_open_file_fs_event(&self, event: notify::Event) {
const PREFIX: &str = r"\\?\";
if event.kind.is_modify() {
for path in event.paths {
#[cfg(windows)]
if let Some(path_str) = path.to_str() {
if path_str.starts_with(PREFIX) {
let path = PathBuf::from(&path_str[PREFIX.len()..]);
self.proxy_rpc.notification(
ProxyNotification::OpenFileChanged { path },
);
continue;
}
}
self.proxy_rpc
.notification(ProxyNotification::OpenFileChanged { path });
}