diff options
author | Blaž Hrastnik | 2021-02-18 09:34:22 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-02-18 09:34:22 +0000 |
commit | c9dd1c930edee68a32ef19ee407820c247937b05 (patch) | |
tree | 667de4906e291df3b1dc1e6f71460415e4eb2501 /helix-term | |
parent | bd85460698c8d74f1a7b79c286a627c3ffcfb67e (diff) |
treewide: &RopeSlice -> RopeSlice. It's Copy so no reason to pass by ref
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/application.rs | 4 | ||||
-rw-r--r-- | helix-term/src/commands.rs | 30 | ||||
-rw-r--r-- | helix-term/src/ui/editor.rs | 8 |
3 files changed, 21 insertions, 21 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 79a916a5..90391024 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -147,8 +147,8 @@ impl Application { .into_iter() .map(|diagnostic| { use helix_lsp::util::lsp_pos_to_pos; - let start = lsp_pos_to_pos(&doc, diagnostic.range.start); - let end = lsp_pos_to_pos(&doc, diagnostic.range.end); + let start = lsp_pos_to_pos(doc, diagnostic.range.start); + let end = lsp_pos_to_pos(doc, diagnostic.range.end); helix_core::Diagnostic { range: (start, end), diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index a2f8d20a..621e1223 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -117,7 +117,7 @@ pub fn move_next_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); // TODO: count - let pos = State::move_next_word_start(&doc.text().slice(..), doc.selection().cursor()); + let pos = State::move_next_word_start(doc.text().slice(..), doc.selection().cursor()); doc.set_selection(Selection::point(pos)); } @@ -125,7 +125,7 @@ pub fn move_next_word_start(cx: &mut Context) { pub fn move_prev_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let pos = State::move_prev_word_start(&doc.text().slice(..), doc.selection().cursor()); + let pos = State::move_prev_word_start(doc.text().slice(..), doc.selection().cursor()); doc.set_selection(Selection::point(pos)); } @@ -133,7 +133,7 @@ pub fn move_prev_word_start(cx: &mut Context) { pub fn move_next_word_end(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let pos = State::move_next_word_end(&doc.text().slice(..), doc.selection().cursor(), count); + let pos = State::move_next_word_end(doc.text().slice(..), doc.selection().cursor(), count); doc.set_selection(Selection::point(pos)); } @@ -156,7 +156,7 @@ pub fn extend_next_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); let mut selection = doc.selection().transform(|mut range| { - let pos = State::move_next_word_start(&doc.text().slice(..), doc.selection().cursor()); + let pos = State::move_next_word_start(doc.text().slice(..), doc.selection().cursor()); range.head = pos; range }); // TODO: count @@ -168,7 +168,7 @@ pub fn extend_prev_word_start(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); let mut selection = doc.selection().transform(|mut range| { - let pos = State::move_prev_word_start(&doc.text().slice(..), doc.selection().cursor()); + let pos = State::move_prev_word_start(doc.text().slice(..), doc.selection().cursor()); range.head = pos; range }); // TODO: count @@ -179,7 +179,7 @@ pub fn extend_next_word_end(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); let mut selection = doc.selection().transform(|mut range| { - let pos = State::move_next_word_end(&doc.text().slice(..), doc.selection().cursor(), count); + let pos = State::move_next_word_end(doc.text().slice(..), doc.selection().cursor(), count); range.head = pos; range }); // TODO: count @@ -303,7 +303,7 @@ pub fn select_all(cx: &mut Context) { pub fn select_regex(cx: &mut Context) { let prompt = ui::regex_prompt(cx, "select:".to_string(), |doc, regex| { - let text = &doc.text().slice(..); + let text = doc.text().slice(..); // TODO: if select on matches returns empty range, we need to abort let selection = selection::select_on_matches(text, doc.selection(), ®ex).expect("no matches"); @@ -331,7 +331,7 @@ pub fn split_selection(cx: &mut Context) { // } let prompt = ui::regex_prompt(cx, "split:".to_string(), |doc, regex| { - let text = &doc.text().slice(..); + let text = doc.text().slice(..); let selection = selection::split_on_matches(text, doc.selection(), ®ex); doc.set_selection(selection); }); @@ -345,7 +345,7 @@ pub fn split_selection(cx: &mut Context) { pub fn split_selection_on_newline(cx: &mut Context) { let doc = cx.doc(); - let text = &doc.text().slice(..); + let text = doc.text().slice(..); // only compile the regex once #[allow(clippy::trivial_regex)] static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"\n").unwrap()); @@ -489,7 +489,7 @@ pub fn append_mode(cx: &mut Context) { doc.restore_cursor = true; // TODO: as transaction - let text = &doc.text().slice(..); + let text = doc.text().slice(..); let selection = doc.selection().transform(|range| { // TODO: to() + next char Range::new( @@ -721,7 +721,7 @@ pub fn normal_mode(cx: &mut Context) { // if leaving append mode, move cursor back by 1 if doc.restore_cursor { - let text = &doc.text().slice(..); + let text = doc.text().slice(..); let selection = doc.selection().transform(|range| { Range::new( range.from(), @@ -775,7 +775,7 @@ pub mod insert { pub fn delete_char_backward(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let text = &doc.text().slice(..); + let text = doc.text().slice(..); let transaction = Transaction::change_by_selection(&doc.state, |range| { ( graphemes::nth_prev_grapheme_boundary(text, range.head, count), @@ -789,7 +789,7 @@ pub mod insert { pub fn delete_char_forward(cx: &mut Context) { let count = cx.count; let doc = cx.doc(); - let text = &doc.text().slice(..); + let text = doc.text().slice(..); let transaction = Transaction::change_by_selection(&doc.state, |range| { ( range.head, @@ -826,7 +826,7 @@ pub fn yank(cx: &mut Context) { let values = doc .state .selection() - .fragments(&doc.text().slice(..)) + .fragments(doc.text().slice(..)) .map(|cow| cow.into_owned()) .collect(); @@ -978,7 +978,7 @@ pub fn completion(cx: &mut Context) { let doc = cx.doc(); // TODO: blocking here is not ideal - let pos = helix_lsp::util::pos_to_lsp_pos(&doc.text().slice(..), doc.selection().cursor()); + let pos = helix_lsp::util::pos_to_lsp_pos(doc.text().slice(..), doc.selection().cursor()); // TODO: handle fails let res = diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 22e80623..7d812116 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -134,7 +134,7 @@ impl EditorView { let mut char_index = start; // iterate over range char by char - for grapheme in RopeGraphemes::new(&text) { + for grapheme in RopeGraphemes::new(text) { // TODO: track current char_index if grapheme == "\n" { @@ -211,8 +211,8 @@ impl EditorView { .filter(|range| range.overlaps(&screen)) { // TODO: render also if only one of the ranges is in viewport - let mut start = view.screen_coords_at_pos(&text, selection.anchor); - let mut end = view.screen_coords_at_pos(&text, selection.head); + let mut start = view.screen_coords_at_pos(text, selection.anchor); + let mut end = view.screen_coords_at_pos(text, selection.head); // cursor if let Some(end) = end { @@ -439,7 +439,7 @@ impl Component for EditorView { let cursor = view.doc.state.selection().cursor(); let mut pos = view - .screen_coords_at_pos(&view.doc.text().slice(..), cursor) + .screen_coords_at_pos(view.doc.text().slice(..), cursor) .expect("Cursor is out of bounds."); pos.col += view.area.x as usize + area.x as usize + OFFSET as usize; pos.row += view.area.y as usize + area.y as usize; |