Skip to content

Commit

Permalink
No text insertion while doing tooltip update only
Browse files Browse the repository at this point in the history
For #297
  • Loading branch information
Code7R committed Nov 10, 2024
1 parent e6ee573 commit 0c097bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/yinputline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -353,7 +354,6 @@ bool YInputLine::handleKey(const XKeyEvent &key) {
}
break;
case XK_Tab:
simu_tab:
complete();
break;
default:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion src/yinputline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0c097bb

Please sign in to comment.