diff --git a/Sources/Splash/Grammar/SwiftGrammar.swift b/Sources/Splash/Grammar/SwiftGrammar.swift index 3ef2f92..8e0570e 100644 --- a/Sources/Splash/Grammar/SwiftGrammar.swift +++ b/Sources/Splash/Grammar/SwiftGrammar.swift @@ -216,7 +216,7 @@ private extension SwiftGrammar { if let previousToken = segment.tokens.previous { // Don't highlight most keywords when used as a parameter label - if !segment.tokens.current.isAny(of: "_", "self", "let", "var") { + if !segment.tokens.current.isAny(of: "_", "self", "let", "var", "true", "false") { guard !previousToken.isAny(of: "(", ",") else { return false } diff --git a/Tests/SplashTests/Tests/FunctionCallTests.swift b/Tests/SplashTests/Tests/FunctionCallTests.swift index 7d46283..48ef8c4 100644 --- a/Tests/SplashTests/Tests/FunctionCallTests.swift +++ b/Tests/SplashTests/Tests/FunctionCallTests.swift @@ -119,6 +119,17 @@ final class FunctionCallTests: SyntaxHighlighterTestCase { ]) } + func testPassingBoolToUnnamedArgument() { + let components = highlighter.highlight("setCachingEnabled(true)") + + XCTAssertEqual(components, [ + .token("setCachingEnabled", .call), + .plainText("("), + .token("true", .keyword), + .plainText(")") + ]) + } + func testAllTestsRunOnLinux() { XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests)) } @@ -134,7 +145,8 @@ extension FunctionCallTests { ("testAccessingPropertyAfterFunctionCallWithoutArguments", testAccessingPropertyAfterFunctionCallWithoutArguments), ("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments), ("testCallingStaticMethodOnGenericType", testCallingStaticMethodOnGenericType), - ("testPassingTypeToFunction", testPassingTypeToFunction) + ("testPassingTypeToFunction", testPassingTypeToFunction), + ("testPassingBoolToUnnamedArgument", testPassingBoolToUnnamedArgument) ] } }