From 79cc71d1628c017cb9651c5bf0830505dc88b3bb Mon Sep 17 00:00:00 2001 From: dezza <402927+dezza@users.noreply.github.com> Date: Wed, 26 Feb 2025 15:29:17 +0100 Subject: [PATCH] fix(snippets): escape literal $ Continuation and more complete version of https://github.com/bash-lsp/bash-language-server/pull/1181 --- server/src/snippets.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/snippets.ts b/server/src/snippets.ts index 5f4718055..9165d9694 100644 --- a/server/src/snippets.ts +++ b/server/src/snippets.ts @@ -154,7 +154,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'if-defined', documentation: 'if with variable existence check', insertText: [ - 'if [[ -n "${${1:variable}+x}" ]]; then', + 'if [[ -n "\\${${1:variable}+x}" ]]; then', '\t${2:command ...}', 'fi', ].join('\n'), @@ -163,7 +163,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'if-not-defined', documentation: 'if with variable existence check', insertText: [ - 'if [[ -z "${${1:variable}+x}" ]]; then', + 'if [[ -z "\\${${1:variable}+x}" ]]; then', '\t${2:command ...}', 'fi', ].join('\n'), @@ -278,7 +278,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'while-defined', documentation: 'while with variable existence check', insertText: [ - 'while [[ -n "${${1:variable}+x}" ]]', + 'while [[ -n "\\${${1:variable}+x}" ]]', '\t${2:command ...}', 'done', ].join('\n'), @@ -287,7 +287,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'while-not-defined', documentation: 'while with variable existence check', insertText: [ - 'while [[ -z "${${1:variable}+x}" ]]', + 'while [[ -z "\\${${1:variable}+x}" ]]', '\t${2:command ...}', 'done', ].join('\n'), @@ -402,7 +402,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'until-defined', documentation: 'until with variable existence check', insertText: [ - 'until [[ -n "${${1:variable}+x}" ]]', + 'until [[ -n "\\${${1:variable}+x}" ]]', '\t${2:command ...}', 'done', ].join('\n'), @@ -411,7 +411,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'until-not-defined', documentation: 'until with variable existence check', insertText: [ - 'until [[ -z "${${1:variable}+x}" ]]', + 'until [[ -z "\\${${1:variable}+x}" ]]', '\t${2:command ...}', 'done', ].join('\n'), @@ -429,7 +429,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'for-range', documentation: 'for with range', insertText: [ - 'for ${1:item} in $(seq ${2:from} ${3:to}); do', + 'for ${1:item} in \\$(seq ${2:from} ${3:to}); do', '\t${4:command ...}', 'done', ].join('\n'), @@ -438,7 +438,7 @@ export const SNIPPETS: BashCompletionItem[] = [ label: 'for-stepped-range', documentation: 'for with stepped range', insertText: [ - 'for ${1:item} in $(seq ${2:from} ${3:step} ${4:to}); do', + 'for ${1:item} in \\$(seq ${2:from} ${3:step} ${4:to}); do', '\t${5:command ...}', 'done', ].join('\n'),