diff options
author | Ivan Tham | 2021-11-03 03:02:29 +0000 |
---|---|---|
committer | GitHub | 2021-11-03 03:02:29 +0000 |
commit | 3eb829e2330fed5ad1c095f8bba44f62361b4943 (patch) | |
tree | 400ee47dd753eb318774f9ab02934f0e70b92597 /helix-term/src | |
parent | ee889aaa854d0036da3bae16252bc382e50b0df6 (diff) |
Ensure coords in screen depends on char width (#885)
The issue affected files with lots of tabs at the start as well.
Fix #840
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/ui/completion.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index dcb2bfd8..dd782d29 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -264,12 +264,10 @@ impl Component for Completion { .language() .and_then(|scope| scope.strip_prefix("source.")) .unwrap_or(""); - let cursor_pos = doc - .selection(view.id) - .primary() - .cursor(doc.text().slice(..)); - let cursor_pos = (helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row - - view.offset.row) as u16; + let text = doc.text().slice(..); + let cursor_pos = doc.selection(view.id).primary().cursor(text); + let coords = helix_core::visual_coords_at_pos(text, cursor_pos, doc.tab_width()); + let cursor_pos = (coords.row - view.offset.row) as u16; let mut markdown_doc = match &option.documentation { Some(lsp::Documentation::String(contents)) | Some(lsp::Documentation::MarkupContent(lsp::MarkupContent { |