Don't merge keymap contexts from containing elements

Co-Authored-By: Aaron Hillegass <charmedliferaft@gmail.com>
This commit is contained in:
Nathan Sobo 2021-12-24 13:05:30 -07:00
parent 9fc2ddb8da
commit e9a750be71
2 changed files with 9 additions and 2 deletions

View File

@ -1047,6 +1047,11 @@ impl Editor {
let buffer = self.buffer.read(cx).snapshot(cx);
let mut oldest_selection = self.oldest_selection::<usize>(&buffer);
if self.selection_count() == 1 {
if oldest_selection.is_empty() {
cx.propagate_action();
return;
}
oldest_selection.start = oldest_selection.head().clone();
oldest_selection.end = oldest_selection.head().clone();
}

View File

@ -1164,8 +1164,7 @@ impl MutableAppContext {
let mut context = keymap::Context::default();
for view_id in &responder_chain {
if let Some(view) = self.cx.views.get(&(window_id, *view_id)) {
context.extend(view.keymap_context(self.as_ref()));
context_chain.push(context.clone());
context_chain.push(view.keymap_context(self.as_ref()));
} else {
return Err(anyhow!(
"View {} in responder chain does not exist",
@ -4094,7 +4093,10 @@ mod tests {
let mut view_2 = View::new(2);
let mut view_3 = View::new(3);
view_1.keymap_context.set.insert("a".into());
view_2.keymap_context.set.insert("a".into());
view_2.keymap_context.set.insert("b".into());
view_3.keymap_context.set.insert("a".into());
view_3.keymap_context.set.insert("b".into());
view_3.keymap_context.set.insert("c".into());
let (window_id, view_1) = cx.add_window(Default::default(), |_| view_1);