Permalink
Browse files

Fix infinite loop problem in iedit-rect-mode

Also add a new test case
  • Loading branch information...
1 parent 79d0f4f commit 83c037d678956dde584b77bbca698e6a74cedbdb @victorhge committed Jan 31, 2013
Showing with 26 additions and 17 deletions.
  1. +18 −15 iedit-rect.el
  2. +8 −2 iedit-tests.el
View
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2013-01-18 17:24:41 Victor Ren>
+;; Time-stamp: <2013-02-04 01:35:54 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -116,21 +116,24 @@ Commands:
(when (< end-col beg-col)
(rotatef beg-col end-col))
(goto-char beg)
- (loop do (progn
- (push (iedit-make-occurrence-overlay
- (progn
- (move-to-column beg-col t)
- (point))
- (progn
- (move-to-column end-col t)
- (point)))
- iedit-occurrences-overlays)
- (forward-line 1))
- until (> (point) end))))
+ (while
+ (progn
+ (push (iedit-make-occurrence-overlay
+ (progn
+ (move-to-column beg-col t)
+ (point))
+ (progn
+ (move-to-column end-col t)
+ (point)))
+ iedit-occurrences-overlays)
+ (and (< (point) end) (forward-line 1))))))
(setq iedit-rectangle (list beg end))
- (setq iedit-rectangle-mode (propertize
- (concat " Iedit-rect:" (number-to-string (length iedit-occurrences-overlays)))
- 'face 'font-lock-warning-face))
+ (setq iedit-rectangle-mode
+ (propertize
+ (concat " Iedit-rect:"
+ (number-to-string (length iedit-occurrences-overlays)))
+ 'face
+ 'font-lock-warning-face))
(force-mode-line-update)
(add-hook 'kbd-macro-termination-hook 'iedit-rectangle-done nil t)
(add-hook 'change-major-mode-hook 'iedit-rectangle-done nil t)
View
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2013-01-19 22:18:17 Victor Ren>
+;; Time-stamp: <2013-02-01 00:10:47 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.97
;; X-URL: http://www.emacswiki.org/emacs/Iedit
@@ -473,7 +473,13 @@ fob")))))
(forward-char 3)
(forward-line 3)
(call-interactively 'iedit-rectangle-mode)
- (should (equal (marker-position-list iedit-rectangle) '(1 19))))))
+ (should (equal (marker-position-list iedit-rectangle) '(1 19)))
+ (call-interactively 'iedit-rectangle-mode)
+ (goto-char (point-min))
+ (set-mark-command nil)
+ (goto-char (point-max))
+ (call-interactively 'iedit-rectangle-mode)
+ (should (equal (marker-position-list iedit-rectangle) '(1 33))))))
(ert-deftest iedit-kill-rectangle-error-test ()
(with-iedit-test-fixture

0 comments on commit 83c037d

Please sign in to comment.