From 21442bd2b7366997d7a138dbcf3a05073d69e0e9 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 27 Apr 2021 13:49:02 +0200 Subject: [PATCH] Don't propagate action when selecting up/down in single-line editors --- zed/src/editor/buffer_view.rs | 56 +++++++++++++++-------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/zed/src/editor/buffer_view.rs b/zed/src/editor/buffer_view.rs index 2b044a3ed0..87d8fd9c81 100644 --- a/zed/src/editor/buffer_view.rs +++ b/zed/src/editor/buffer_view.rs @@ -796,24 +796,20 @@ impl BufferView { } pub fn select_up(&mut self, _: &(), ctx: &mut ViewContext) { - if self.single_line { - ctx.propagate_action(); - } else { - let mut selections = self.selections(ctx.as_ref()).to_vec(); - { - let app = ctx.as_ref(); - let buffer = self.buffer.read(app); - let map = self.display_map.read(app); - for selection in &mut selections { - let head = selection.head().to_display_point(map, app).unwrap(); - let (head, goal_column) = - movement::up(map, head, selection.goal_column, app).unwrap(); - selection.set_head(&buffer, map.anchor_before(head, Bias::Left, app).unwrap()); - selection.goal_column = goal_column; - } + let mut selections = self.selections(ctx.as_ref()).to_vec(); + { + let app = ctx.as_ref(); + let buffer = self.buffer.read(app); + let map = self.display_map.read(app); + for selection in &mut selections { + let head = selection.head().to_display_point(map, app).unwrap(); + let (head, goal_column) = + movement::up(map, head, selection.goal_column, app).unwrap(); + selection.set_head(&buffer, map.anchor_before(head, Bias::Left, app).unwrap()); + selection.goal_column = goal_column; } - self.update_selections(selections, true, ctx); } + self.update_selections(selections, true, ctx); } pub fn move_down(&mut self, _: &(), ctx: &mut ViewContext) { @@ -845,24 +841,20 @@ impl BufferView { } pub fn select_down(&mut self, _: &(), ctx: &mut ViewContext) { - if self.single_line { - ctx.propagate_action(); - } else { - let mut selections = self.selections(ctx.as_ref()).to_vec(); - { - let app = ctx.as_ref(); - let buffer = self.buffer.read(app); - let map = self.display_map.read(app); - for selection in &mut selections { - let head = selection.head().to_display_point(map, app).unwrap(); - let (head, goal_column) = - movement::down(map, head, selection.goal_column, app).unwrap(); - selection.set_head(&buffer, map.anchor_before(head, Bias::Right, app).unwrap()); - selection.goal_column = goal_column; - } + let mut selections = self.selections(ctx.as_ref()).to_vec(); + { + let app = ctx.as_ref(); + let buffer = self.buffer.read(app); + let map = self.display_map.read(app); + for selection in &mut selections { + let head = selection.head().to_display_point(map, app).unwrap(); + let (head, goal_column) = + movement::down(map, head, selection.goal_column, app).unwrap(); + selection.set_head(&buffer, map.anchor_before(head, Bias::Right, app).unwrap()); + selection.goal_column = goal_column; } - self.update_selections(selections, true, ctx); } + self.update_selections(selections, true, ctx); } pub fn move_to_beginning(&mut self, _: &(), ctx: &mut ViewContext) {