jeff-hykin / better-shell-syntax

💾 📦 ♻️ An improvement to the shell syntax for VS Code
MIT License
52 stars 4 forks source link

Left shift is being recognized as heredoc #93

Open alexr00 opened 4 months ago

alexr00 commented 4 months ago

The code with a problem is:

#! /bin/bash

i=$(( 1 + 2))
i=$(( 1 << 2 ))
i=$((1 << 2))
i=$(( 1 + 2 ))
i=$((i<<2))

It looks like:

image

The scopes:

keyword.operator.heredoc.shell
meta.argument.shell
meta.statement.command.shell
meta.statement.shell
meta.parenthese.group.shell
meta.scope.subshell
meta.expression.assignment.shell
source.shell

It should look like:

After the unexpected heredoc scope, the following lines end up with a heredoc scope, when instead they should be colored similarly to line 3.

Originally from @skyp0714 in https://github.com/microsoft/vscode/issues/215908

sonic2kk commented 3 months ago

Facing this exact issue as well. Seems other editors have the exact same issue. When searching, I found numerous reports of this for Vim, and I am also experiencing this with the Kate editor.

Is there a workaround in the meantime? Is there a comment I can put somewhere to temporarily correct the highlighting? I maintain a large Bash script and this is going to cause broken highlighting for a few thousand lines :sweat_smile:

skyp0714 commented 3 months ago

There is a workaround using the power operator (). Devide or multiply 2(shift num) inside the arithmetic operator.

E.g)$(( a << 3 )) to $(( a *(2**3) ))

On Sun, Jul 14, 2024 at 1:13 PM Eamonn Rea @.***> wrote:

Facing this exact issue as well. Seems other editors have the exact same issue. When searching, I found numerous reports of this for Vim, and I am also experiencing this with the Kate editor.

Is there a workaround in the meantime? Is there a comment I can put somewhere to temporarily correct the highlighting? I maintain a large Bash script and this is going to cause broken highlighting for a few thousand lines 😅

— Reply to this email directly, view it on GitHub https://github.com/jeff-hykin/better-shell-syntax/issues/93#issuecomment-2227435860, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXQNNQPJ5ZQ2HVJDIIOGQTZMK5TFAVCNFSM6AAAAABJRY3CB2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRXGQZTKOBWGA . You are receiving this because you were mentioned.Message ID: @.***>

jeff-hykin commented 3 months ago

should be fixed on v1.10.0!

alexr00 commented 2 months ago

@jeff-hykin is this one that you plan to port to master?

jeff-hykin commented 1 month ago

@jeff-hykin is this one that you plan to port to master?

Yes, thanks for reminding me