Skip to content

Commit abd6f87

Browse files
committed
Fix Imenu for open curly braces on its own line
Fix #173.
1 parent 4ec7c73 commit abd6f87

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

swift-mode-imenu.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@ Return found declarations in reverse order."
109109
(while (not done)
110110
(setq next-token
111111
(swift-mode:forward-token-or-list-except-curly-bracket))
112+
(when (and (eq (swift-mode:token:type next-token) 'implicit-\;)
113+
(save-excursion
114+
(swift-mode:skip-whitespaces)
115+
(eq (char-after) ?\{)))
116+
(setq next-token (swift-mode:forward-token)))
112117
(setq next-type (swift-mode:token:type next-token))
113118
(setq next-text (swift-mode:token:text next-token))
114-
115119
(cond
116120
((equal next-text "import")
117121
;; Skips an import kind, for example, "class" token below:
@@ -147,7 +151,7 @@ Return found declarations in reverse order."
147151
(swift-mode:declaration
148152
'class
149153
name-token
150-
(when (eq (swift-mode:token:type next-token) '{)
154+
(when (eq next-type '{)
151155
(nreverse (swift-mode:scan-declarations))))
152156
declarations)))
153157

@@ -267,6 +271,11 @@ KEYWORD-TOKEN is the keyword beginning the declaration like \"struct\" or
267271
(swift-mode:forward-token-or-list-except-curly-bracket))
268272
(not (memq (swift-mode:token:type next-token)
269273
'(\; implicit-\; { } outside-of-buffer)))))
274+
(when (and (eq (swift-mode:token:type next-token) 'implicit-\;)
275+
(save-excursion
276+
(swift-mode:skip-whitespaces)
277+
(eq (char-after) ?\{)))
278+
(setq next-token (swift-mode:forward-token)))
270279
(swift-mode:declaration
271280
(intern (swift-mode:token:text keyword-token))
272281
name-token

0 commit comments

Comments
 (0)