From 2667f9476b9c668215924c01583cb687fa537c0e Mon Sep 17 00:00:00 2001 From: ian` <71764999+dist-ian@users.noreply.github.com> Date: Sat, 23 Jul 2022 00:01:54 +0700 Subject: [PATCH] Fix "hard" indent column info on status view. (#1078) * Fix "hard" indent column info on status view. * Update tabs calculation and add "byte" number info * Add config.show_char_byte_info * Add show char byte toggle command. it should be added on the commands/statusbar.lua, but there is no config module loaded before and i won't to add it. * Update config.lua * Update statusview.lua --- data/core/statusview.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/data/core/statusview.lua b/data/core/statusview.lua index 182c782a..59065682 100644 --- a/data/core/statusview.lua +++ b/data/core/statusview.lua @@ -222,6 +222,20 @@ function StatusView:register_docview_items() get_item = function() local dv = core.active_view local line, col = dv.doc:get_selection() + local _, indent_size = dv.doc:get_indent_info() + -- Calculating tabs when the doc is using the "hard" indent type. + local ntabs = 0 + local last_idx = 0 + while last_idx < col do + local s, e = string.find(dv.doc.lines[line], "\t", last_idx, true) + if s and s < col then + ntabs = ntabs + 1 + last_idx = e + 1 + else + break + end + end + col = col + ntabs * (indent_size - 1) return { style.text, line, ":", col > config.line_limit and style.accent or style.text, col, @@ -1159,5 +1173,4 @@ function StatusView:draw() end end - return StatusView