branch: elpa/symbol-overlay
commit 03da3c1d43e6dcfbbd24bbf1f15a9f2a7558bde7
Merge: 6a3c16e506 4a70f6d999
Author: wolray <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #11 from purcell/patch-2
When renaming, don't add coloured highlight if there wasn't previously one
---
symbol-overlay.el | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/symbol-overlay.el b/symbol-overlay.el
index 10ec8e3a90..4dd471b67a 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -519,14 +519,16 @@ DIR must be 1 or -1."
(substring symbol 3 -3))
new (symbol-overlay-get-symbol txt))
(unless (string= new symbol)
- (symbol-overlay-maybe-remove (symbol-overlay-assoc new))
- (save-excursion
- (save-restriction
- (symbol-overlay-narrow scope)
- (goto-char (point-min))
- (let ((inhibit-modification-hooks t))
- (while (re-search-forward symbol nil t) (replace-match txt t)))))
- (setq keyword (symbol-overlay-put-all new scope keyword)))
+ (let ((prev-overlay (symbol-overlay-assoc new)))
+ (symbol-overlay-maybe-remove prev-overlay)
+ (save-excursion
+ (save-restriction
+ (symbol-overlay-narrow scope)
+ (goto-char (point-min))
+ (let ((inhibit-modification-hooks t))
+ (while (re-search-forward symbol nil t) (replace-match txt
t)))))
+ (when prev-overlay
+ (setq keyword (symbol-overlay-put-all new scope keyword)))))
(when (string= new (symbol-overlay-get-symbol nil t))
(symbol-overlay-maybe-count keyword)))))