From 4d4d72587185fb485fd6826514241680fc2d02ba Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 3 Aug 2024 12:35:21 +0200 Subject: fix cursor rendering in editor --- src/widgets/luaeditor/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/widgets') 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(), }) } -- cgit v1.2.3-70-g09d2