zsh-syntax-highlighting icon indicating copy to clipboard operation
zsh-syntax-highlighting copied to clipboard

Highlight parameter expansion history modifiers

Open danielshahaf opened this issue 7 years ago • 7 comments

$foo:hey should highlight $foo:h as a parameter expansion.

  • both within and without quotes
  • modifiers can be chained, $foo:h:h:t

danielshahaf avatar Jan 17 '18 02:01 danielshahaf

Modifiers require braces when KSH_ARRAYS is set.

danielshahaf avatar Jan 19 '18 00:01 danielshahaf

According to zshexpn, modifiers are:

  • :[aAcehlpPqQ&tuxfw]
  • :s/l/r[/] , :gs/x/y/, :s/x/y/:G where the delimiter can vary
  • :F:expr: where the delimiter can vary
  • :W:sep: likewise

danielshahaf avatar Jan 19 '18 01:01 danielshahaf

@phy1729 You mentioned having some pending changes to this area of the code, please unassign yourself once they've been merged to master (to avoid needless conflicts). Thanks!

danielshahaf avatar Jan 19 '18 01:01 danielshahaf

I've implemented something that covers the modifiers that take no argument: https://github.com/zsh-users/zsh-syntax-highlighting/compare/master...danielshahaf:i485-history-modifiers-v1

... but if I wrote a regression test, it would conflict with #492, so instead I just described the regression test I would create (pending manual verification, of course) and I'll put this on hold pending #492's merge.

danielshahaf avatar Jan 20 '18 16:01 danielshahaf

I think that bit and the parameter handling in _highlight_arguments should be pulled out into a new function. Not sure what to do about the style. Perhaps parameter with a fallback to dollar-double-quoted-argument?

phy1729 avatar Jan 21 '18 03:01 phy1729

dollar-un-quoted-argument (maybe without that ungrammatical hyphen) would be consistent. variable or parameter-expansion would work.

danielshahaf avatar Jan 21 '18 07:01 danielshahaf

Triage: https://github.com/zsh-users/zsh-syntax-highlighting/pull/697#issuecomment-632442416

danielshahaf avatar May 22 '20 02:05 danielshahaf