Skip to content

Commit 5074a02

Browse files
committed
Fix font-lock of successive identifiers
Example: ```swift enum Foo: Error { .foo } ``` `Foo` was not fontified with `swift-mode:function-name-face`.
1 parent 95ff004 commit 5074a02

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

swift-mode-font-lock.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ The predicate MATCH-P is called with two arguments:
361361
(let ((result nil))
362362
(while (and
363363
(< (point) limit)
364-
(re-search-forward "\\<\\(\\sw\\|\\s_\\)+\\>" limit t)
365-
(not result))
364+
(not result)
365+
(re-search-forward "\\<\\(\\sw\\|\\s_\\)+\\>" limit t))
366366
(when (save-excursion
367367
(save-match-data
368368
(funcall match-p (match-beginning 0) limit)))

test/swift-files/font-lock/font-lock.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ foo != bar // "foo != bar"
3030

3131
foo !== bar // "foo !== bar"
3232

33-
a.b.c! // #("a.b.c!" 4 5 (face swift-mode:property-access-face))
33+
a.b.c! // #("a.b.c!" 2 3 (face swift-mode:property-access-face) 4 5 (face swift-mode:property-access-face))
3434

35-
a.b.c_! // #("a.b.c_!" 4 5 (face swift-mode:property-access-face))
35+
a.b.c_! // #("a.b.c_!" 2 3 (face swift-mode:property-access-face) 4 5 (face swift-mode:property-access-face))
3636

37-
a.b.aあ! // #("a.b.a\343\201\202!" 4 8 (face swift-mode:property-access-face))
37+
a.b.aあ! // #("a.b.a\343\201\202!" 2 3 (face swift-mode:property-access-face) 4 8 (face swift-mode:property-access-face))
3838

3939
init! {} // #("init! {}" 0 4 (face swift-mode:keyword-face))
4040

@@ -45,7 +45,13 @@ let x = foo()! // #("let x = foo()!" 0 3 (face swift-mode:keyword-face) 8 11 (fa
4545
let x = foo[0]! // #("let x = foo[0]!" 0 3 (face swift-mode:keyword-face))
4646

4747
// Identifiers can be quoted.
48-
a.b.`c`! // #("a.b.`c`!" 4 7 (face font-lock-string-face))
48+
a.b.`c`! // #("a.b.`c`!" 2 3 (face swift-mode:property-access-face) 4 7 (face font-lock-string-face))
4949

5050
// Custom operators.
5151
foo +!+!+!+!+ bbb // "foo +!+!+!+!+ bbb"
52+
53+
//
54+
// Regression tests.
55+
//
56+
57+
enum Foo: Error { .foo } // #("enum Foo: Error { .foo }" 0 4 (face swift-mode:keyword-face) 5 8 (face swift-mode:function-name-face) 10 15 (face swift-mode:builtin-type-face) 19 22 (face swift-mode:property-access-face))

0 commit comments

Comments
 (0)