summaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-19 16:25:10 +0000
committerNathan Vegdahl2021-07-19 16:25:10 +0000
commitb0311f4fc246f370bb317ab0b1fcb89823347caa (patch)
tree7bb7f6783cdba83d784af2bcbd780e57a32c715c /helix-term/src/ui/editor.rs
parent079d4ed86df30c78ca00fd4b86f906c3ea9df7db (diff)
Fixed primary cursor position calculation to use 1-width semantics.
This had a bunch of knock-on effects that were buggy, such as bracket match highlighting.
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 6a588e12..acf60905 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -398,7 +398,7 @@ 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();
+ let pos = doc.selection(view.id).cursor(doc.text().slice(..));
let pos = match_brackets::find(syntax, doc.text(), pos)
.and_then(|pos| view.screen_coords_at_pos(doc, text, pos));
@@ -443,7 +443,7 @@ impl EditorView {
widgets::{Paragraph, Widget},
};
- let cursor = doc.selection(view.id).cursor();
+ let cursor = doc.selection(view.id).cursor(doc.text().slice(..));
let diagnostics = doc.diagnostics().iter().filter(|diagnostic| {
diagnostic.range.start <= cursor && diagnostic.range.end >= cursor
@@ -555,7 +555,10 @@ impl EditorView {
// _ => "indent:ERROR",
// };
let position_info = {
- let pos = coords_at_pos(doc.text().slice(..), doc.selection(view.id).cursor());
+ let pos = coords_at_pos(
+ doc.text().slice(..),
+ doc.selection(view.id).cursor(doc.text().slice(..)),
+ );
format!("{}:{}", pos.row + 1, pos.col + 1) // convert to 1-indexing
};