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

[Bug] unexpected behavior when ABBR_EXPANSION_CURSOR_MARKER set to caret #140

Closed
2 tasks done
olets opened this issue Jun 16, 2024 · 6 comments
Closed
2 tasks done
Labels
bug Something isn't working priority: low

Comments

@olets
Copy link
Owner

olets commented Jun 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Update the issue title

  • I have updated the title

Expected Behavior

Can use an arbitrary string as the ABBR_EXPANSION_CURSOR_MARKER.

Actual Behavior

If ABBR_EXPANSION_CURSOR_MARKER is ^, \^, '^', expansions without the cursor marker are doubled, with the cursor between them.

Steps To Reproduce

% ABBR_EXPANSION_CURSOR_MARKER='^'
% abbr a=b
% a[SPACE] # expands to `b[CURSOR]b`

Environment

zsh-abbr version 5.8.0
zsh 5.9 (arm-apple-darwin21.3.0)
OSTYPE darwin21.3.0

Installation method

Plugin manager

Installation method details

zcomet

Anything else?

@olets olets added needs triage bug Something isn't working priority: low and removed needs triage labels Jun 16, 2024
@olets olets changed the title [Bug report] unexpected behavior when ABBR_EXPANSION_CURSOR_MARKER set to caret [Bug] unexpected behavior when ABBR_EXPANSION_CURSOR_MARKER set to caret Jun 16, 2024
@qadzek
Copy link

qadzek commented Jun 21, 2024

Instead of fixing this bug and supporting a caret as ABBR_LINE_CURSOR_MARKER (I have no idea how complicated that would be), maybe the documentation could just suggest a couple of characters that are known to work without issues?

I did change the default ABBR_LINE_CURSOR_MARKER from % to ^ because % would break abbreviations like abbr -g cdate="\$(date +'%F')". I have now changed it to @, and that seems to behave as expected.

By the way, after reading the documentation again, I learned about "context-dependent abbreviations" and "building command templates", which are both very cool features!

@olets
Copy link
Owner Author

olets commented Jun 25, 2024

maybe the documentation could just suggest a couple of characters that are known to work without issues

Good idea. Rather than doing that exactly, I've added callouts for a few limitations

@qadzek
Copy link

qadzek commented Jul 16, 2024

For future reference: changing the special character to @ wasn't a wise decision, as it caused issues with commands like ssh user@hostname.
It seems that Unicode characters are accepted as well, so I'm now using U+2503 to avoid any further conflicts.

ABBR_EXPANSION_CURSOR_MARKER=┃
ABBR_LINE_CURSOR_MARKER=┃

@olets olets added this to zsh-abbr Jul 29, 2024
@olets olets moved this to Nice To Have in zsh-abbr Jul 29, 2024
olets added a commit that referenced this issue Nov 8, 2024
Previously, setting one or both markers to '+'
resulted in an error:

> zsh: failed to compile regex: repetition-operator operand invalid

And when one or both markers was '^', expansions without the cursor
marker were doubled, with the cursor between them.
@olets
Copy link
Owner Author

olets commented Nov 8, 2024

The upcoming v6.0.0 will fix this

@olets olets moved this from Nice To Have to Ready in zsh-abbr Nov 8, 2024
@qadzek
Copy link

qadzek commented Nov 9, 2024

Nice. I'm looking forward to v6. I guess I'll stick to using that Unicode character though, as I'll never use it in a command, unlike the caret.

@olets
Copy link
Owner Author

olets commented Nov 12, 2024

Cool yeah I like the idea of using a Unicode character that I'd have to paste, that I can't type

Released in v6.0.0

@olets olets closed this as completed Nov 12, 2024
@github-project-automation github-project-automation bot moved this from Ready to Done in zsh-abbr Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: low
Projects
Status: Done
Development

No branches or pull requests

2 participants