From 71489251f459255c5133bc584ea10636a6f24712 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 28 May 2021 15:06:32 -0700 Subject: [PATCH] Rename context parameters to `cx` in movement.rs --- zed/src/editor/movement.rs | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/zed/src/editor/movement.rs b/zed/src/editor/movement.rs index f7e89776ecf1d3fd24dc90e03b689ea5f63de22f..d7af40858b91edc86827b863dca9810dc00861d9 100644 --- a/zed/src/editor/movement.rs +++ b/zed/src/editor/movement.rs @@ -2,34 +2,34 @@ use super::{Bias, DisplayMap, DisplayPoint, SelectionGoal}; use anyhow::Result; use gpui::AppContext; -pub fn left(map: &DisplayMap, mut point: DisplayPoint, app: &AppContext) -> Result { +pub fn left(map: &DisplayMap, mut point: DisplayPoint, cx: &AppContext) -> Result { if point.column() > 0 { *point.column_mut() -= 1; } else if point.row() > 0 { *point.row_mut() -= 1; - *point.column_mut() = map.line_len(point.row(), app); + *point.column_mut() = map.line_len(point.row(), cx); } - Ok(map.snapshot(app).clip_point(point, Bias::Left)) + Ok(map.snapshot(cx).clip_point(point, Bias::Left)) } -pub fn right(map: &DisplayMap, mut point: DisplayPoint, app: &AppContext) -> Result { - let max_column = map.line_len(point.row(), app); +pub fn right(map: &DisplayMap, mut point: DisplayPoint, cx: &AppContext) -> Result { + let max_column = map.line_len(point.row(), cx); if point.column() < max_column { *point.column_mut() += 1; - } else if point.row() < map.max_point(app).row() { + } else if point.row() < map.max_point(cx).row() { *point.row_mut() += 1; *point.column_mut() = 0; } - Ok(map.snapshot(app).clip_point(point, Bias::Right)) + Ok(map.snapshot(cx).clip_point(point, Bias::Right)) } pub fn up( map: &DisplayMap, mut point: DisplayPoint, goal: SelectionGoal, - app: &AppContext, + cx: &AppContext, ) -> Result<(DisplayPoint, SelectionGoal)> { - let map = map.snapshot(app); + let map = map.snapshot(cx); let goal_column = if let SelectionGoal::Column(column) = goal { column } else { @@ -50,10 +50,10 @@ pub fn down( map: &DisplayMap, mut point: DisplayPoint, goal: SelectionGoal, - app: &AppContext, + cx: &AppContext, ) -> Result<(DisplayPoint, SelectionGoal)> { - let max_point = map.max_point(app); - let map = map.snapshot(app); + let max_point = map.max_point(cx); + let map = map.snapshot(cx); let goal_column = if let SelectionGoal::Column(column) = goal { column } else { @@ -74,9 +74,9 @@ pub fn line_beginning( map: &DisplayMap, point: DisplayPoint, toggle_indent: bool, - app: &AppContext, + cx: &AppContext, ) -> Result { - let (indent, is_blank) = map.line_indent(point.row(), app); + let (indent, is_blank) = map.line_indent(point.row(), cx); if toggle_indent && !is_blank && point.column() != indent { Ok(DisplayPoint::new(point.row(), indent)) } else { @@ -84,30 +84,30 @@ pub fn line_beginning( } } -pub fn line_end(map: &DisplayMap, point: DisplayPoint, app: &AppContext) -> Result { +pub fn line_end(map: &DisplayMap, point: DisplayPoint, cx: &AppContext) -> Result { Ok(DisplayPoint::new( point.row(), - map.line_len(point.row(), app), + map.line_len(point.row(), cx), )) } pub fn prev_word_boundary( map: &DisplayMap, point: DisplayPoint, - app: &AppContext, + cx: &AppContext, ) -> Result { if point.column() == 0 { if point.row() == 0 { Ok(DisplayPoint::new(0, 0)) } else { let row = point.row() - 1; - Ok(DisplayPoint::new(row, map.line_len(row, app))) + Ok(DisplayPoint::new(row, map.line_len(row, cx))) } } else { let mut boundary = DisplayPoint::new(point.row(), 0); let mut column = 0; let mut prev_c = None; - for c in map.snapshot(app).chars_at(boundary) { + for c in map.snapshot(cx).chars_at(boundary) { if column >= point.column() { break; } @@ -126,10 +126,10 @@ pub fn prev_word_boundary( pub fn next_word_boundary( map: &DisplayMap, mut point: DisplayPoint, - app: &AppContext, + cx: &AppContext, ) -> Result { let mut prev_c = None; - for c in map.snapshot(app).chars_at(point) { + for c in map.snapshot(cx).chars_at(point) { if prev_c.is_some() && (c == '\n' || char_kind(prev_c.unwrap()) != char_kind(c)) { break; }