diff --git a/src/dockerfile/dockerfile.test.ts b/src/dockerfile/dockerfile.test.ts index 2a5122a9..1c1c7ca1 100644 --- a/src/dockerfile/dockerfile.test.ts +++ b/src/dockerfile/dockerfile.test.ts @@ -223,5 +223,21 @@ testTokenization('dockerfile', [ { startIndex: 45, type: 'string.dockerfile' } ] } + ], + [ + { + line: "RUN \\'e\\'", + tokens: [ + { startIndex: 0, type: 'keyword.dockerfile' }, + { startIndex: 3, type: '' } + ] + }, + { + line: 'RUN echo hi this is # not a comment', + tokens: [ + { startIndex: 0, type: 'keyword.dockerfile' }, + { startIndex: 3, type: '' } + ] + } ] ]); diff --git a/src/dockerfile/dockerfile.ts b/src/dockerfile/dockerfile.ts index 0e8f35f6..c21d5aa4 100644 --- a/src/dockerfile/dockerfile.ts +++ b/src/dockerfile/dockerfile.ts @@ -99,6 +99,8 @@ export const language = { // Recognize strings, including those broken across lines with \ (but not without) strings: [ + [/\\'$/, '', '@popall'], // \' leaves @arguments at eol + [/\\'/, ''], // \' is not a string [/'$/, 'string', '@popall'], [/'/, 'string', '@stringBody'], [/"$/, 'string', '@popall'],