jeff-hykin / better-shell-syntax

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

Shell script syntax highlighting fails with indented EOT HereDoc #97

Open alexr00 opened 1 month ago

alexr00 commented 1 month ago

The code with a problem is:

#!/bin/sh
foo=$(cat <<'    EOT'
        A HereDoc
    EOT
)
echo "$foo"

It looks like:

Image

The scopes at the beginning of the EOT line include this no-indent scope:

string.quoted.heredoc.no-indent.EOT
meta.argument.shell
meta.statement.command.shell
meta.statement.shell
meta.scope.subshell
meta.expression.assignment.shell
source.shell

Image

It should look like:

Image

Originally from @sandy-fairsupply in https://github.com/microsoft/vscode/issues/223443

sandy-fairsupply commented 1 month ago

Small correction:

It should look like:

screenshot showing how it should look with the closing EOT marker indented and coloured correctly

Note that the closing EOT marker is preceded by four spaces to match the opening marker.

RedCMD commented 2 weeks ago

image should be easy fix either place \\s* before \\3 or capture the [ \\t]*+ and replace \\3 with \\3?\\4