summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-08-03 12:35:21 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2024-08-03 12:35:21 +0200
commit4d4d72587185fb485fd6826514241680fc2d02ba (patch)
tree523daf17851fe0f518ade26f30fd520e0287748d /src
parent69790321ae1a3cc2239b28398579eb9bdcab8aa7 (diff)
fix cursor rendering in editor
Diffstat (limited to 'src')
-rw-r--r--src/widgets/luaeditor/mod.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widgets/luaeditor/mod.rs b/src/widgets/luaeditor/mod.rs
index 0dcda9f..4fb8a3b 100644
--- a/src/widgets/luaeditor/mod.rs
+++ b/src/widgets/luaeditor/mod.rs
@@ -54,12 +54,14 @@ impl LuaEditor {
let state = GlobalState::instance();
let buffer = &state.editor.buffer;
let nr_width = (buffer.lines().len().to_string().len() + 1).max(4) as u16;
+ let x = buffer.cursor().x()
+ + buffer.current_line()[..buffer.cursor().x()]
+ .chars()
+ .filter(|c| *c == '\t')
+ .count();
Some(TuiCursor {
- position: (
- buffer.cursor().y() as u16,
- buffer.cursor().x() as u16 + nr_width,
- ),
+ position: (buffer.cursor().y() as u16, x as u16 + nr_width),
style: state.editor.cursor_shape.into(),
})
}