Skip to content

Backslash-newline mid-token causes highlight offset #741

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

Open
phy1729 opened this issue May 26, 2020 · 2 comments
Open

Backslash-newline mid-token causes highlight offset #741

phy1729 opened this issue May 26, 2020 · 2 comments

Comments

@phy1729
Copy link
Member

phy1729 commented May 26, 2020

Idea from zsh-users/zsh@40723b3

# PREBUFFER=$'echo $\\\n'
# BUFFER=$'(echo foo)'
not ok 1 - [1,8] «(echo fo» - expected (1 10 "default"), observed (1 8 "default").
not ok 2 - [1,8] «(echo fo» - expected (1 10 "command-substitution-unquoted"), observed (1 8 "command-substitution-unquoted").
not ok 3 - [1,3] «(ec» - expected (1 1 "command-substitution-delimiter-unquoted"), observed (1 3 "builtin").
not ok 4 - [5,7] «o f» - expected (2 5 "builtin"), observed (5 7 "default").
not ok 5 - [8,8] «o» - expected (7 9 "default"), observed (8 8 "command-substitution-delimiter-unquoted").
not ok 6 - unmatched expectation (10 10 command-substitution-delimiter-unquoted)
not ok 7 - cardinality check - have 6 expectations and 5 region_highlight entries: «expected_region_highlight=( $'1 10 default' $'1 10 command-substitution-unquoted' $'1 1 command-substitution-delimiter-unquoted' $'2 5 builtin' $'7 9 default' $'10 10 command-substitution-delimiter-unquoted' )» «region_highlight=( $'0 8 default' $'0 8 command-substitution-unquoted' $'0 3 builtin' $'4 7 default' $'7 8 command-substitution-delimiter-unquoted' )»
# expected_region_highlight                        region_highlight
# '1 10 default'                                   '0 8 default'
# '1 10 command-substitution-unquoted'             '0 8 command-substitution-unquoted'
# '1 1 command-substitution-delimiter-unquoted'    '0 3 builtin'
# '2 5 builtin'                                    '4 7 default'
# '7 9 default'                                    '7 8 command-substitution-delimiter-unquoted'
# '10 10 command-substitution-delimiter-unquoted'

Adding

      [[ $arg == '$('* && ${proc_buf[offset + 1,offset + 4]} == $'$\\\n(' ]] && { proc_buf=${proc_buf[3,len]}; buf_offset+=2; }

after

[[ $arg == ';' && ${match[3]} == $'\n' ]] && arg=$'\n'
fixes the issue, but that's clearly too specific.

@danielshahaf
Copy link
Member

danielshahaf commented May 26, 2020 via email

@phy1729
Copy link
Member Author

phy1729 commented May 26, 2020

I was tempted to add the label too. Applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants