From 0273d31da57e2356c0bfa544be52fef6445e5d45 Mon Sep 17 00:00:00 2001 From: Sorawee Porncharoenwase Date: Sun, 6 Sep 2020 16:35:37 -0700 Subject: [PATCH] Only rename identifiers that are textually equal It is possible to have an arrow between two identifiers that are not textually equivalent (definitely possible in DrRacket, and theoretically possible in Racket Mode). In the above event, renaming one identifier should not change the other. See also racket/drracket#415 for a similar fix in DrRacket, and racket/racket#3391 which would start to make Racket Mode behave incorrectly. In particular, with the above PR, renaming the identifier `a` in the following program should not rename `all-defined-out` as well. #lang racket (provide (all-defined-out)) (define a 1) --- racket-xp.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/racket-xp.el b/racket-xp.el index dc61ff84..d45535c8 100644 --- a/racket-xp.el +++ b/racket-xp.el @@ -551,9 +551,10 @@ If point is instead on a definition, then go to its first use." (dolist (marker-pair marker-pairs) (let ((beg (marker-position (nth 0 marker-pair))) (end (marker-position (nth 1 marker-pair)))) - (delete-region beg end) - (goto-char beg) - (insert new-id)))) + (when (string= (buffer-substring-no-properties beg end) old-id) + (delete-region beg end) + (goto-char beg) + (insert new-id))))) (goto-char (marker-position point-marker)) (racket-xp-annotate)))