diff options
author | Nathan Vegdahl | 2021-07-26 15:40:30 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-07-26 15:40:30 +0000 |
commit | 0883b4fae03343978e61fc377775d7ba93f86b40 (patch) | |
tree | 1a3d6fe100b39a2cae88842017e441aa3e96707a /helix-term/src/ui/editor.rs | |
parent | f96b8b769b3c7457935b5c02db870af97036f7b6 (diff) |
Collect some common patterns into methods on `Range`.
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r-- | helix-term/src/ui/editor.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 8e29be6c..482a4117 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -406,7 +406,10 @@ impl EditorView { // TODO: set cursor position for IME if let Some(syntax) = doc.syntax() { use helix_core::match_brackets; - let pos = doc.selection(view.id).cursor(doc.text().slice(..)); + let pos = doc + .selection(view.id) + .primary() + .cursor(doc.text().slice(..)); let pos = match_brackets::find(syntax, doc.text(), pos) .and_then(|pos| view.screen_coords_at_pos(doc, text, pos)); @@ -451,7 +454,10 @@ impl EditorView { widgets::{Paragraph, Widget}, }; - let cursor = doc.selection(view.id).cursor(doc.text().slice(..)); + let cursor = doc + .selection(view.id) + .primary() + .cursor(doc.text().slice(..)); let diagnostics = doc.diagnostics().iter().filter(|diagnostic| { diagnostic.range.start <= cursor && diagnostic.range.end >= cursor @@ -565,7 +571,9 @@ impl EditorView { let position_info = { let pos = coords_at_pos( doc.text().slice(..), - doc.selection(view.id).cursor(doc.text().slice(..)), + doc.selection(view.id) + .primary() + .cursor(doc.text().slice(..)), ); format!("{}:{}", pos.row + 1, pos.col + 1) // convert to 1-indexing }; |