Skip to content
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

Shell Language - Syntax Highlight breaks with substring matching #20502

Closed
1 task done
GrabbenD opened this issue Nov 11, 2024 · 2 comments
Closed
1 task done

Shell Language - Syntax Highlight breaks with substring matching #20502

GrabbenD opened this issue Nov 11, 2024 · 2 comments
Labels
bash Bash scripting support bug [core label] tree-sitter Syntax highlighting and tree-sitter

Comments

@GrabbenD
Copy link

GrabbenD commented Nov 11, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Substring matching breaks syntax highlight in ZED (which doesn't happen with VSCode nor GitHub Markdown).

Bash 5.2 enables substring matching by default (see patsub_replacement). This is particularly useful for injecting strings, but only when a $variable is present. In this example --volume=/tmp/mnt:/mnt wont be printed unless item in export MOUNTS is uncommented:

#!/usr/bin/env bash

export MOUNTS=(
  #/tmp/mnt:/mnt
)

export PARAMS=(
  "${MOUNTS[@]/*/'--volume='&}"
  --tty='1'
  --interactive='1'
)

podman run "${PARAMS[@]}" archlinux
# podman run --tty=1 --interactive=1 archlinux

Reproducible example:

PARENT_FUNC() {
  local LIST=(1 2)
  export ITEMIZED=(
    #"${LIST[@]/*/'prefix'&'suffix'}" # OK
    "${LIST[@]/*/'prefix'&}"          # BREAKS HIGHLIGHT
  )

  NESTED_FUNC() {
    echo "${ITEMIZED[@]}"  # prefix1 prefix2
  }
}

PARENT_FUNC
NESTED_FUNC

Environment

Zed: v0.159.7 (Zed)
OS: Arch Linux Wayland
Memory: 62.6 GiB
Architecture: x86_64
GPU: AMD Radeon RX 7900 XT (RADV NAVI31) || radv || Mesa 24.1.3-arch1.1


If applicable, add mockups / screenshots to help explain present your vision of the feature

ZED without any extensions:

  • OK
    highligh_ok

  • BROKEN
    highlight_broken

For reference, I've also tried installing d1y/bash.zed (extensions/basher) & rburmorrison/shell.zed (extensions/shell) but either behaves identically as ZED with no extensions

@GrabbenD GrabbenD added admin read bug [core label] labels Nov 11, 2024
@SomeoneToIgnore
Copy link
Contributor

which doesn't happen with VSCode nor GitHub Markdown

They use different approaches to highlights, and whatever tree-sitter grammar in Zed is used, it seems to have issues with it.
It seems that this report should go to https://github.com/tree-sitter/tree-sitter-bash and not here.

@GrabbenD
Copy link
Author

tree-sitter/tree-sitter-bash#279

@notpeter notpeter added tree-sitter Syntax highlighting and tree-sitter bash Bash scripting support and removed triage labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash Bash scripting support bug [core label] tree-sitter Syntax highlighting and tree-sitter
Projects
None yet
Development

No branches or pull requests

3 participants