emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/swift-mode abd6f87 1/4: Fix Imenu for open curly braces on


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode abd6f87 1/4: Fix Imenu for open curly braces on its own line
Date: Sat, 9 Oct 2021 02:57:49 -0400 (EDT)

branch: elpa/swift-mode
commit abd6f87aacd5b643a3d181561e6108d61d69db13
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>

    Fix Imenu for open curly braces on its own line
    
    Fix https://github.com/swift-emacs/swift-mode/issues/173.
---
 swift-mode-imenu.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/swift-mode-imenu.el b/swift-mode-imenu.el
index effdc68..0e171fe 100644
--- a/swift-mode-imenu.el
+++ b/swift-mode-imenu.el
@@ -109,9 +109,13 @@ Return found declarations in reverse order."
     (while (not done)
       (setq next-token
             (swift-mode:forward-token-or-list-except-curly-bracket))
+      (when (and (eq (swift-mode:token:type next-token) 'implicit-\;)
+                 (save-excursion
+                   (swift-mode:skip-whitespaces)
+                   (eq (char-after) ?\{)))
+        (setq next-token (swift-mode:forward-token)))
       (setq next-type (swift-mode:token:type next-token))
       (setq next-text (swift-mode:token:text next-token))
-
       (cond
        ((equal next-text "import")
         ;; Skips an import kind, for example, "class" token below:
@@ -147,7 +151,7 @@ Return found declarations in reverse order."
              (swift-mode:declaration
               'class
               name-token
-              (when (eq (swift-mode:token:type next-token) '{)
+              (when (eq next-type '{)
                 (nreverse (swift-mode:scan-declarations))))
              declarations)))
 
@@ -267,6 +271,11 @@ KEYWORD-TOKEN is the keyword beginning the declaration 
like \"struct\" or
                      (swift-mode:forward-token-or-list-except-curly-bracket))
                (not (memq (swift-mode:token:type next-token)
                           '(\; implicit-\; { } outside-of-buffer)))))
+      (when (and (eq (swift-mode:token:type next-token) 'implicit-\;)
+                 (save-excursion
+                   (swift-mode:skip-whitespaces)
+                   (eq (char-after) ?\{)))
+        (setq next-token (swift-mode:forward-token)))
       (swift-mode:declaration
        (intern (swift-mode:token:text keyword-token))
        name-token



reply via email to

[Prev in Thread] Current Thread [Next in Thread]