diff --git a/lua/harpoon/mark.lua b/lua/harpoon/mark.lua index 3f498d7..7b2465b 100644 --- a/lua/harpoon/mark.lua +++ b/lua/harpoon/mark.lua @@ -11,10 +11,17 @@ local callbacks = {} -- need one event emitted local function emit_changed() log.trace("_emit_changed()") - if harpoon.get_global_settings().save_on_change then + + local global_settings = harpoon.get_global_settings() + + if global_settings.save_on_change then harpoon.save() end + if global_settings.tabline then + vim.cmd("redrawt") + end + if not callbacks["changed"] then log.trace("_emit_changed(): no callbacks for 'changed', returning") return diff --git a/lua/harpoon/tabline.lua b/lua/harpoon/tabline.lua index 2030c27..cc6f874 100644 --- a/lua/harpoon/tabline.lua +++ b/lua/harpoon/tabline.lua @@ -32,14 +32,22 @@ end function M.setup(opts) function _G.tabline() - local original_tabs = require('harpoon').get_mark_config().marks - local tabs = shorten_filenames(original_tabs) + local tabs = shorten_filenames(require('harpoon').get_mark_config().marks) local tabline = '' - for i, tab in ipairs(original_tabs) do - local is_current = string.match(vim.fn.bufname(), tab.filename) or vim.fn.bufname() == tab.filename + local index = require('harpoon.mark').get_index_of(vim.fn.bufname()) - local label = tabs[i].filename + for i, tab in ipairs(tabs) do + local is_current = i == index + + local label + + if tab.filename == "" or tab.filename == "(empty)" then + label = "(empty)" + is_current = false + else + label = tab.filename + end if is_current then @@ -51,6 +59,7 @@ function M.setup(opts) end tabline = tabline .. label .. (opts.tabline_suffix or ' ') .. '%*' + if i < #tabs then tabline = tabline .. '%T' end