Do not clear cache for default prettiers
This commit is contained in:
parent
6ec3927dd3
commit
afee29ad3f
2 changed files with 39 additions and 36 deletions
|
@ -155,6 +155,9 @@ async function handleMessage(message, prettier) {
|
||||||
parser: params.options.parser,
|
parser: params.options.parser,
|
||||||
path: params.options.path
|
path: params.options.path
|
||||||
};
|
};
|
||||||
|
// TODO kb always resolve prettier config for each file.
|
||||||
|
// need to understand if default prettier can be affected by other configs in the project
|
||||||
|
// (restart default prettiers on config changes too then)
|
||||||
const formattedText = await prettier.prettier.format(params.text, options);
|
const formattedText = await prettier.prettier.format(params.text, options);
|
||||||
sendResponse({ id, result: { text: formattedText } });
|
sendResponse({ id, result: { text: formattedText } });
|
||||||
} else if (method === 'prettier/clear_cache') {
|
} else if (method === 'prettier/clear_cache') {
|
||||||
|
|
|
@ -6391,13 +6391,11 @@ impl Project {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Prettier config file {config_path:?} changed, reloading prettier instances for worktree {current_worktree_id}"
|
"Prettier config file {config_path:?} changed, reloading prettier instances for worktree {current_worktree_id}"
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
let prettiers_to_reload = self
|
let prettiers_to_reload = self
|
||||||
.prettier_instances
|
.prettier_instances
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|((worktree_id, prettier_path), prettier_task)| {
|
.filter_map(|((worktree_id, prettier_path), prettier_task)| {
|
||||||
if worktree_id.is_none() || worktree_id == &Some(current_worktree_id) {
|
if worktree_id == &Some(current_worktree_id) {
|
||||||
Some((*worktree_id, prettier_path.clone(), prettier_task.clone()))
|
Some((*worktree_id, prettier_path.clone(), prettier_task.clone()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -6429,6 +6427,7 @@ impl Project {
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_active_path(&mut self, entry: Option<ProjectPath>, cx: &mut ModelContext<Self>) {
|
pub fn set_active_path(&mut self, entry: Option<ProjectPath>, cx: &mut ModelContext<Self>) {
|
||||||
let new_active_entry = entry.and_then(|project_path| {
|
let new_active_entry = entry.and_then(|project_path| {
|
||||||
|
@ -8410,6 +8409,7 @@ impl Project {
|
||||||
project
|
project
|
||||||
.supplementary_language_servers
|
.supplementary_language_servers
|
||||||
.insert(new_server_id, (name, Arc::clone(prettier.server())));
|
.insert(new_server_id, (name, Arc::clone(prettier.server())));
|
||||||
|
// TODO kb could there be a race with multiple default prettier instances added?
|
||||||
cx.emit(Event::LanguageServerAdded(new_server_id));
|
cx.emit(Event::LanguageServerAdded(new_server_id));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue