summaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/completion.rs8
-rw-r--r--helix-term/src/ui/editor.rs9
2 files changed, 10 insertions, 7 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index be6db42c..942a2483 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -86,7 +86,7 @@ impl Completion {
let item = item.unwrap();
// if more text was entered, remove it
- let cursor = doc.selection(view.id).cursor();
+ let cursor = doc.selection(view.id).cursor(doc.text().slice(..));
if trigger_offset < cursor {
let remove = Transaction::change(
doc.text(),
@@ -109,7 +109,7 @@ impl Completion {
)
} else {
let text = item.insert_text.as_ref().unwrap_or(&item.label);
- let cursor = doc.selection(view.id).cursor();
+ let cursor = doc.selection(view.id).cursor(doc.text().slice(..));
Transaction::change(
doc.text(),
vec![(cursor, cursor, Some(text.as_str().into()))].into_iter(),
@@ -155,7 +155,7 @@ impl Completion {
// TODO: hooks should get processed immediately so maybe do it after select!(), before
// looping?
- let cursor = doc.selection(view.id).cursor();
+ let cursor = doc.selection(view.id).cursor(doc.text().slice(..));
if self.trigger_offset <= cursor {
let fragment = doc.text().slice(self.trigger_offset..cursor);
let text = Cow::from(fragment);
@@ -212,7 +212,7 @@ impl Component for Completion {
.language()
.and_then(|scope| scope.strip_prefix("source."))
.unwrap_or("");
- let cursor_pos = doc.selection(view.id).cursor();
+ let cursor_pos = doc.selection(view.id).cursor(doc.text().slice(..));
let cursor_pos = (helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row
- view.first_line) as u16;
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
};