olets / zsh-abbr

The zsh manager for auto-expanding abbreviations, inspired by fish. ~13,000 unique cloners as of May '24, 580+ Homebrew installs 6/23-6/24
https://zsh-abbr.olets.dev
Other
508 stars 18 forks source link

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

Open olets opened 2 weeks ago

olets commented 2 weeks ago

Is there an existing issue for this?

Update the issue 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?

qadzek commented 1 week ago

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 commented 1 week ago

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