From 0c097bbd7c904ee56649c7bfef6e4588f347eac7 Mon Sep 17 00:00:00 2001 From: Eduard Bloch Date: Sun, 10 Nov 2024 15:44:11 +0100 Subject: [PATCH] No text insertion while doing tooltip update only For #297 --- src/yinputline.cc | 12 ++++++++---- src/yinputline.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/yinputline.cc b/src/yinputline.cc index 63d02169c..437232960 100644 --- a/src/yinputline.cc +++ b/src/yinputline.cc @@ -344,7 +344,8 @@ bool YInputLine::handleKey(const XKeyEvent &key) { if (toolTipVisible()) { // must kill the timer! toolTipVisibility(false); - goto simu_tab; + complete(true); + break; } return true; } @@ -353,7 +354,6 @@ bool YInputLine::handleKey(const XKeyEvent &key) { } break; case XK_Tab: - simu_tab: complete(); break; default: @@ -831,7 +831,7 @@ void passCompCand(const void *param, const char * const *name, unsigned cnt) { } } -void YInputLine::complete() { +void YInputLine::complete(bool previewOnly) { lastSeenCandidates = new tCandCollector; auto& glob_cand = *lastSeenCandidates; @@ -863,7 +863,7 @@ void YInputLine::complete() { int res_count = globit_best(mstr, &res, &passCompCand, &glob_cand); fcsmart cleaner(res); - if (glob_cand.hits.size() > 1) { + if (glob_cand.hits.size() > 1 || previewOnly) { //mstring all; // mstring is crap, .append does not append toolTipVisibility(true); @@ -876,6 +876,10 @@ void YInputLine::complete() { toolTipVisibility(false); } + // this was a plain call to update the tooltip preview, not inserting yet + if (previewOnly) + return; + // directory is not a final match if (res_count == 1 && upath(res).dirExists()) res_count++; diff --git a/src/yinputline.h b/src/yinputline.h index 6635b4aa5..1ccc7bdd0 100644 --- a/src/yinputline.h +++ b/src/yinputline.h @@ -72,7 +72,7 @@ class YInputLine: void unselectAll(); bool cutSelection(); bool copySelection(); - void complete(); + void complete(bool previewOnly = false); protected: virtual bool handleTimer(YTimer *timer);