From 30a786cf5ffdaae51c4ef3b31b78bb5df6997f6f Mon Sep 17 00:00:00 2001 From: yuri1969 <1969yuri1969@gmail.com> Date: Wed, 22 Mar 2023 23:06:07 +0100 Subject: [PATCH] Fix incorrect key:value detection --- src/basic-languages/yaml/yaml.test.ts | 50 +++++++++++++++++++++++++++ src/basic-languages/yaml/yaml.ts | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/basic-languages/yaml/yaml.test.ts b/src/basic-languages/yaml/yaml.test.ts index 6a0aa846..db7810bd 100644 --- a/src/basic-languages/yaml/yaml.test.ts +++ b/src/basic-languages/yaml/yaml.test.ts @@ -473,5 +473,55 @@ testTokenization('yaml', [ { startIndex: 10, type: 'comment.yaml' } ] } + ], + + // ': ' in double-quoted Value + [ + { + line: 'key: "va: lue"', + tokens: [ + { + startIndex: 0, + type: 'type.yaml' + }, + { + startIndex: 3, + type: 'operators.yaml' + }, + { + startIndex: 4, + type: 'white.yaml' + }, + { + startIndex: 5, + type: 'string.yaml' + } + ] + } + ], + + // ': ' in single-quoted Value + [ + { + line: "key: 'va: lue'", + tokens: [ + { + startIndex: 0, + type: 'type.yaml' + }, + { + startIndex: 3, + type: 'operators.yaml' + }, + { + startIndex: 4, + type: 'white.yaml' + }, + { + startIndex: 5, + type: 'string.yaml' + } + ] + } ] ]); diff --git a/src/basic-languages/yaml/yaml.ts b/src/basic-languages/yaml/yaml.ts index 466be144..51b8f50a 100644 --- a/src/basic-languages/yaml/yaml.ts +++ b/src/basic-languages/yaml/yaml.ts @@ -86,7 +86,7 @@ export const language = { [/@numberDate(?![ \t]*\S+)/, 'number.date'], // Key:Value pair - [/(".*?"|'.*?'|.*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']], + [/(".*?"|'.*?'|[^'"]*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']], { include: '@flowScalars' },