Blur focused view when project becomes read-only

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-03-04 17:28:53 +01:00
parent b21d91db22
commit 77e913b5a4
3 changed files with 37 additions and 20 deletions

View file

@ -576,7 +576,13 @@ pub struct Workspace {
impl Workspace {
pub fn new(params: &WorkspaceParams, cx: &mut ViewContext<Self>) -> Self {
cx.observe(&params.project, |_, _, cx| cx.notify()).detach();
cx.observe(&params.project, |_, project, cx| {
if project.read(cx).is_read_only() {
cx.blur();
}
cx.notify()
})
.detach();
let pane = cx.add_view(|_| Pane::new(params.settings.clone()));
let pane_id = pane.id();