From 6fc24048ca8a4a6cf06b09c30e8d6aec4ebe6374 Mon Sep 17 00:00:00 2001 From: Kossak <3728245+tkossak@users.noreply.github.com> Date: Wed, 8 Jul 2026 19:22:03 +0200 Subject: [PATCH] Fix interactive prompt: keep reverse-video escape inside readline markers The colored prompt brackets its ANSI escapes with RL_PROMPT_START_IGNORE (\001) and RL_PROMPT_END_IGNORE (\002) so readline does not count them toward the prompt width. In the reverse-video opener, \002 was placed before the terminating 'm' of \x1b[7m, leaving 'm' outside the ignore region. readline counted it as a visible column, making the prompt one column wider than it renders. That off-by-one shifted readline's input-start position, so Backspace could not delete the first typed character. Move \002 to after the 'm' so the whole \x1b[7m sits inside the markers. This fixes both PROMPTMSG (reverse-video prompt) and the per-DB prompt suffix. --- buku.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buku.py b/buku.py index d4d313a9..43135356 100755 --- a/buku.py +++ b/buku.py @@ -4695,7 +4695,7 @@ def prompt(obj, results, noninteractive=False, deep=False, listtags=False, sugge prompt_suffix = '' if bdb.dbfile != os.path.realpath(os.path.join(BukuDb.get_default_dbdir(), 'bookmarks.db')): prompt_suffix = (f'[{bdb.dbname}] ' if not bdb.colorize else - f'\001\x1b[7\002m[{bdb.dbname}]\001\x1b[0m\002 ') + f'\001\x1b[7m\002[{bdb.dbname}]\001\x1b[0m\002 ') nav = read_in(PROMPTMSG + prompt_suffix) if not nav: nav = read_in(PROMPTMSG + prompt_suffix) @@ -6154,7 +6154,7 @@ def main(argv=sys.argv[1:], *, program_name=os.path.basename(sys.argv[0])): setup_logger(LOGGER) # Enable prompt with reverse video - PROMPTMSG = '\001\x1b[7\002mbuku (? for help)\001\x1b[0m\002 ' + PROMPTMSG = '\001\x1b[7m\002buku (? for help)\001\x1b[0m\002 ' # Enable browser output in case of a text based browser if os.getenv('BROWSER') in TEXT_BROWSERS: