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

Syntax Highlight breaks with substring matching #279

Open
GrabbenD opened this issue Nov 12, 2024 · 1 comment
Open

Syntax Highlight breaks with substring matching #279

GrabbenD opened this issue Nov 12, 2024 · 1 comment

Comments

@GrabbenD
Copy link

GrabbenD commented Nov 12, 2024

Issue Overview

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

Screenshots

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

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

@CattoFace
Copy link

CattoFace commented Nov 16, 2024

also happens with the % syntax on NeoVim, single liner that removes file extension and breaks tree-sitter:
removed=${filename%.*}
syntax highlighting for the entire file is gone, both in bash file and a markdown file containing a bash code block.
I'm getting the following error log, I'm using a nearly unmodified LazyVim:

   Error  18:40:35 msg_show.emsg Error in decoration provider treesitter/highlighter.win:
Error executing lua: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 9:4.
 Invalid node type "":
  "<"
   ^

stack traceback:
> [C]: in function '_ts_parse_query'
> /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
> /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
> /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'get'
> /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:28: in function 'new'
> /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:243: in function 'get_query'
> /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:191: in function 'fn'
> /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:491: in function 'for_each_tree'
> /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:495: in function 'for_each_tree'
> /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:495: in function 'for_each_tree'
> /usr/share/nvim/runtime/

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

No branches or pull requests

2 participants