Avoid using worktree handle in File's path methods

This avoids a circular model update that was happening
when trying to retrieve the absolute path from a buffer's
file while applying remote operations.
This commit is contained in:
Max Brunsfeld
2021-11-02 14:33:55 -07:00
parent 1995bd89a6
commit 89392cd23d
3 changed files with 68 additions and 54 deletions
+3 -3
View File
@@ -77,7 +77,7 @@ impl ItemView for Editor {
.buffer()
.read(cx)
.file()
.and_then(|file| file.file_name(cx));
.and_then(|file| file.file_name());
if let Some(name) = filename {
name.to_string_lossy().into()
} else {
@@ -127,8 +127,8 @@ impl ItemView for Editor {
cx.spawn(|buffer, mut cx| async move {
save_as.await.map(|new_file| {
let (language, language_server) = worktree.read_with(&cx, |worktree, cx| {
let language = worktree.languages().select_language(new_file.full_path(cx));
let (language, language_server) = worktree.read_with(&cx, |worktree, _| {
let language = worktree.languages().select_language(new_file.full_path());
let language_server = worktree.language_server();
(language.cloned(), language_server.cloned())
});