From 4aaff7294131552be8c731e2f4d230106a1149f7 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 21 Nov 2025 22:39:01 +0100 Subject: fixed scrolling the command line after clicking in the popup We cannot rely on the central teco_cmdline_update() call per keypress in this case. The analogous call was removed in 4e6ddd6c329d56055a732c6344df019f0d997aaf, so this was a recent regression. --- src/cmdline.c | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'src/cmdline.c') diff --git a/src/cmdline.c b/src/cmdline.c index fc2a531..e1a4628 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -104,29 +104,6 @@ teco_cmdline_init(void) teco_cmdline_ssm(SCI_MARGINSETTEXT, 0, (sptr_t)"*"); } -static void -teco_cmdline_update(void) -{ - /* - * Update the command line indicators. - * FIXME: Perhaps this can be avoided completely by updating the - * indicators in teco_cmdline_insert(). - */ - gsize effective_len = teco_cmdline_ssm(SCI_GETCURRENTPOS, 0, 0); - gsize macro_len = teco_cmdline_ssm(SCI_GETLENGTH, 0, 0); - teco_cmdline_ssm(SCI_SETINDICATORCURRENT, INDICATOR_RUBBEDOUT, 0); - teco_cmdline_ssm(SCI_INDICATORCLEARRANGE, 0, macro_len); - teco_cmdline_ssm(SCI_INDICATORFILLRANGE, effective_len, macro_len - effective_len); - teco_cmdline_ssm(SCI_SCROLLCARET, 0, 0); - - /* - * FIXME: This gets reset repeatedly. - * Setting it once per keypress however means you can no longer customize - * the margin text. - */ - teco_cmdline_ssm(SCI_MARGINSETTEXT, 0, (sptr_t)"*"); -} - /** * Insert string into command line and execute * it immediately. @@ -480,6 +457,35 @@ teco_cmdline_rubout(void) } } +/** + * Update the command line, i.e. prepare it for displaying. + * + * This updates the indicators and scrolls the caret, which isn't done every time + * we touch the command line itself. + */ +void +teco_cmdline_update(void) +{ + /* + * FIXME: Perhaps this can be avoided completely by updating the + * indicators in teco_cmdline_insert(). + */ + gsize effective_len = teco_cmdline_ssm(SCI_GETCURRENTPOS, 0, 0); + gsize macro_len = teco_cmdline_ssm(SCI_GETLENGTH, 0, 0); + teco_cmdline_ssm(SCI_SETINDICATORCURRENT, INDICATOR_RUBBEDOUT, 0); + teco_cmdline_ssm(SCI_INDICATORCLEARRANGE, 0, macro_len); + teco_cmdline_ssm(SCI_INDICATORFILLRANGE, effective_len, macro_len - effective_len); + + teco_cmdline_ssm(SCI_SCROLLCARET, 0, 0); + + /* + * FIXME: This gets reset repeatedly. + * Setting it once per keypress however means you can no longer customize + * the margin text. + */ + teco_cmdline_ssm(SCI_MARGINSETTEXT, 0, (sptr_t)"*"); +} + void teco_cmdline_cleanup(void) { -- cgit v1.2.3