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

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

[nongnu] elpa/go-mode 87c8b6e 096/495: do not use dangling op cache when


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 87c8b6e 096/495: do not use dangling op cache when buffer is narrowed
Date: Sat, 7 Aug 2021 09:04:51 -0400 (EDT)

branch: elpa/go-mode
commit 87c8b6ee3bcd1a736ce58d94ec4ddcaaa3227ac7
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>

    do not use dangling op cache when buffer is narrowed
---
 go-mode.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 47f45cf..7667ab5 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -151,15 +151,23 @@
         (go--backward-irrelevant stop-at-string))
     (/= start-pos (point))))
 
+(defun go--buffer-narrowed-p ()
+  "Return non-nil if the current buffer is narrowed."
+  (/= (buffer-size)
+      (- (point-max)
+         (point-min))))
+
 (defun go-previous-line-has-dangling-op-p ()
   (let* ((cur-line (line-number-at-pos))
          (val (gethash cur-line go-dangling-cache 'nope)))
-    (if (equal val 'nope)
+    (if (or (go--buffer-narrowed-p) (equal val 'nope))
         (save-excursion
           (beginning-of-line)
           (go--backward-irrelevant t)
-          (puthash cur-line (looking-back go-dangling-operators-regexp) 
go-dangling-cache))
-      val)))
+          (setq val (looking-back go-dangling-operators-regexp))
+          (if (not (go--buffer-narrowed-p))
+              (puthash cur-line val go-dangling-cache))))
+    val))
 
 (defun go-goto-opening-parenthesis (&optional char)
   (let ((start-nesting (go-paren-level)) group)



reply via email to

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