Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treat zle-isearch-exit like an accept-* widget #259

Closed
wants to merge 1 commit into from

Conversation

m0vie
Copy link
Contributor

@m0vie m0vie commented Dec 31, 2015

When hitting ENTER in an isearch, the cursor imprint needs to be removed, and any path_prefix highlighting needs to be removed.

See 4f0c293 and 59fbdda.

Does it make sense to keep this a a user-configurable setting? The pattern matching is a bit complex.
It is ony useful if the user has custom widgets that call accpt-* internally. But then one could argue, that the custom widget name should start with accept-, too.

@danielshahaf
Copy link
Member

Does it make sense to keep this a a user-configurable setting? The pattern matching is a bit complex.

My initial thought is: YAGNI. Let's just have a helper function that does [[ $1 == accept-* ]] || [[ $1 == zsh-isearch-exit ]] and add the additional complexity only when needed.

How do you get path_prefix highlighting while in isearch mode?

@m0vie
Copy link
Contributor Author

m0vie commented Jan 2, 2016

My initial thought is: YAGNI. Let's just have a helper function that does [[ $1 == accept-* ]] || [[ $1 == zsh-isearch-exit ]] and add the additional complexity only when needed.

Done.

How do you get path_prefix highlighting while in isearch mode?
Not while in there, but after

touch fooooooo
vim foo

underlining of foo gets removed when pressing enter.

<^R>vim foo<ENTER>

Underlining stays because accepting an isearch does not call through any of the accept- widgets. However it calls zle-isearch-exit.

@m0vie m0vie changed the title treat more widgets as accept-* kind of widgets and make it configurable treat zle-isearch-exit like an accept-* widget Jan 2, 2016
@danielshahaf
Copy link
Member

Thanks, I can reproduce the issue now. However, I can also reproduce the issue under zsh -f with your patch applied. I suspect your patch only works when a zsh-isearch-exit widget had been created before z-sy-h was loaded.

Is it even possible to write a regression test for this? I'm not sure how hard it'd be to trigger this codepath; would it be as smple as having the test-data/*.zsh file set WIDGET=zsh-isearch-exit? (Test files are isolated from each other: doing this won't affect other test files.)

@danielshahaf
Copy link
Member

Cross-referencing issue #261: this issue might be easier to solve after the redrawhook work (in zsh and in z-sy-h) is done, including the isearch caveat mentioned in #261.

Accepting a line in an iserch does not call through any of the
accept-widgets. To be able to still do some cleanup (remove
cursor imprint, remove partial path highlinting) use
zle-isearch-exit instead.
@m0vie
Copy link
Contributor Author

m0vie commented Jan 3, 2016

Oh, you are right. As long as there is no zsh-isearch-exit widget loaded, this patch is not useful at all.

In a clean zsh -f environment the only widget that is being called when pressing RETURN in an isearch is history-incremental-search-backward.

In the case where zle-isearch-* widgets are defined before loading z-s-h, the order in which widgets are called is this:

zle-isearch-update
zle-isearch-exit
history-incremental-search-backward

So it looks like history-* should be added to the accept-type list, instead of zle-isearch-exit?

@danielshahaf
Copy link
Member

So it looks like history-* should be added to the accept-type list, instead of zle-isearch-exit?

It sounds odd that history-incremental-search-backward is called after zle-isearch-exit. How did you determine the order? Is there any chance that the calltree was:

_zsh_highlight_widget_-history-incremental-search-backward
- .history-incremental-search-backward [built-in widget]
  - zle-isearch-update
    - debug print $WIDGET
  - zle-isearch-exit
    - debug print $WIDGET
- _zsh_highlight
  - debug print $WIDGET

??

@danielshahaf
Copy link
Member

Assuming zle-isearch-exit is indeed the last widget invoked by pressing in isearch mode, what we'd want is for z-sy-h to run code at that point. Conceptually, we'd want to add-zsh-hook zle-isearch-exit _zsh_highlight_isearch_hook [pseudocode!].

Alternatively, perhaps this could be fixed through the redrawhook facility; that would require fixing the upstream issue with redrawhook and isearch (#261 (comment)) and merging one of the redrawhook-based backend implementations (#245).

(And please raise that issue on -workers@ — if the redrawhook work has issues the best time to diagnose/fix them is before it's released.)

@danielshahaf
Copy link
Member

workers/37590 invokes redrawhook from the isearch codepath, which would allow to fix this issue once the z-sy-h uses redrawhook (#245).

@m0vie
Copy link
Contributor Author

m0vie commented Mar 29, 2016

This is the wrong approach for the issue.

The proper way to handle these special cases is to always bind zle-line-finish and use this as indicator.

I'll re-open another pull request with a proper fix.

@m0vie
Copy link
Contributor Author

m0vie commented Mar 29, 2016

Opened issue #284 to track this further.

m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Mar 29, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
@m0vie m0vie mentioned this pull request Apr 2, 2016
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Apr 2, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
@m0vie m0vie deleted the p_accept branch April 3, 2016 00:13
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Apr 10, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Apr 16, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Apr 24, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Apr 29, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Jun 11, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Jun 20, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
m0vie added a commit to m0vie/zsh-syntax-highlighting that referenced this pull request Jun 20, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
danielshahaf pushed a commit to danielshahaf/zsh-syntax-highlighting that referenced this pull request Jul 27, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
danielshahaf pushed a commit to danielshahaf/zsh-syntax-highlighting that referenced this pull request Jul 27, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
@danielshahaf danielshahaf mentioned this pull request Jul 29, 2016
danielshahaf pushed a commit to danielshahaf/zsh-syntax-highlighting that referenced this pull request Jul 29, 2016
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps zsh-users#259.
Fixes zsh-users#284.
danielshahaf added a commit that referenced this pull request Aug 9, 2020
The parent commit, which merged the feature/redrawhook bug and thereby
closed PR #749, also fixed the following issue:

Fixes #40.

Fixes #90, closes #470. (The latter is a PR for the former.)

Fixes #150, closes #151, closes #160. (The latter two are PR's for the first one.) The related issue #183 appears to have been fixed in master. For #150, a different fix for older versions of zsh was considered but has not been implemented.

Issue #154 was fixed in xsel(1) in 2017. The parent commit probably fixed that issue for pre-2017 xsel(1).

Is #245, #356, and #749. Fixes #245 (redrawhook umbrella issue).

Does not reintroduce #257 (comment).

Does not reintroduce #259 (comment)

Closes #281 as obsolete.

Fixes #295.

Fixes #324.

Fixes #375.

Fixes #377.

Closes #421 as obsolete.

Fixes #520.

Unblocks #536 (already milestoned).

Fixes #632.

Unblocks #635. Milestoned.

Unblocks #688. Milestoned.

Unblocks administrative issue #655 (already milestoned).

(The above is copied from
#749 (comment),
but repeated here for the sake of github's commit-to-issue linking magic.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants