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

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

[nongnu] elpa/go-mode 53c76cd 480/495: Speed up slow fontification after


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 53c76cd 480/495: Speed up slow fontification after unclosed parens.
Date: Sat, 7 Aug 2021 09:06:13 -0400 (EDT)

branch: elpa/go-mode
commit 53c76cddf54638dea5e4cae99ce0181de28e1064
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>

    Speed up slow fontification after unclosed parens.
    
    To handle multi line param lists we "expand" the fontification scope
    to the closing paren. If there is no balanced closing paren then we
    expand the scope to the end of the file, which fontifies too much
    stuff and makes typing very slow.
    
    For example, typing is slow at <>:
    
    func (myReceive<>
    
    ... lots of lines in rest of file ...
    
    Add a quick fix to check that the paren is closed by the end of the
    file. If it isn't closed, then don't expand the region. There is more
    work to do here (e.g. func literals inside giant functions will still
    be slow), but this should resolve the worst slowness.
    
    Fixes #335.
    
    Closes: #336 [via git-merge-pr]
---
 go-mode.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 3e85545..8bcc8e4 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1333,9 +1333,15 @@ func foo(i, j int) {}
   ;; multiline param list.
   (save-excursion
     (let ((depth (go-paren-level)))
-      (while (and
-              (re-search-forward ")" nil t)
-              (>= (go-paren-level) depth))))
+      ;; First check that our paren is closed by the end of the file. This
+      ;; avoids expanding the fontification region to the entire file when you
+      ;; have an unclosed paren at file scope.
+      (when (save-excursion
+              (goto-char (1+ (buffer-size)))
+              (< (go-paren-level) depth))
+        (while (and
+                (re-search-forward ")" nil t)
+                (>= (go-paren-level) depth)))))
     (point)))
 
 (defun go--fontify-param-post ()



reply via email to

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