From 1511299d99780055c4bd962d57e2f49e05879b26 Mon Sep 17 00:00:00 2001 From: Osip Fatkullin Date: Tue, 28 Jul 2020 14:03:52 +0300 Subject: [PATCH] Kotlin: make function greedy --- components/prism-kotlin.js | 8 ++++++-- tests/languages/kotlin/function_feature.test | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/prism-kotlin.js b/components/prism-kotlin.js index 1405ade6ce..6b1813c19c 100644 --- a/components/prism-kotlin.js +++ b/components/prism-kotlin.js @@ -9,10 +9,14 @@ lookbehind: true }, 'function': [ - RegExp(/(?=\s*\()/.source.replace('', functionName)), + { + pattern: RegExp(/(?=\s*\()/.source.replace('', functionName)), + greedy: true + }, { pattern: RegExp(/(\.)(?=\s*\{)/.source.replace('', functionName)), - lookbehind: true + lookbehind: true, + greedy: true } ], 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/, diff --git a/tests/languages/kotlin/function_feature.test b/tests/languages/kotlin/function_feature.test index 0966ad4d89..29222ecf0c 100644 --- a/tests/languages/kotlin/function_feature.test +++ b/tests/languages/kotlin/function_feature.test @@ -4,6 +4,7 @@ list.filter {} `function 1`() ` !"#$%^&()*+,=?@{|}~-_`() list.`take 1` {} +`make fun`() ---------------------------------------------------- @@ -15,7 +16,8 @@ list.`take 1` {} ["function", "`function 1`"], ["punctuation", "("], ["punctuation", ")"], ["function", "` !\"#$%^&()*+,=?@{|}~-_`"], ["punctuation", "("], ["punctuation", ")"], "\r\nlist", ["punctuation", "."], - ["function", "`take 1`"], ["punctuation", "{"], ["punctuation", "}"] + ["function", "`take 1`"], ["punctuation", "{"], ["punctuation", "}"], + ["function", "`make fun`"], ["punctuation", "("], ["punctuation", ")"] ] ----------------------------------------------------