diff --git a/iedit-lib.el b/iedit-lib.el index 7697543..b3f1207 100644 --- a/iedit-lib.el +++ b/iedit-lib.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2010, 2011, 2012 Victor Ren -;; Time-stamp: <2013-01-19 00:31:41 Victor Ren> +;; Time-stamp: <2013-01-19 22:00:41 Victor Ren> ;; Author: Victor Ren ;; Keywords: occurrence region simultaneous rectangle refactoring ;; Version: 0.97 @@ -519,20 +519,19 @@ value of `iedit-occurrence-context-lines' is used for this time." (save-excursion (iedit-first-occurrence) (while (/= (point) (point-max)) + ;; Now at the beginning of an occurrence (let ((current-start (point))) (forward-line (- context-lines)) (let ((line-beginning (line-beginning-position))) (if (> line-beginning prev-occurrence-end) - (push (list prev-occurrence-end (1- line-beginning)) unmatched-lines))) - (goto-char current-start)) - ;; goto the end of the occurrence - (goto-char (next-single-char-property-change (point) 'iedit-occurrence-overlay-name)) + (push (list prev-occurrence-end (1- line-beginning)) unmatched-lines))) + ;; goto the end of the occurrence + (goto-char (next-single-char-property-change current-start 'iedit-occurrence-overlay-name))) (let ((current-end (point))) (forward-line context-lines) (setq prev-occurrence-end (1+ (line-end-position))) - (goto-char current-end)) - ;; goto the beginning of next occurrence - (goto-char (next-single-char-property-change (point) 'iedit-occurrence-overlay-name))) + ;; goto the beginning of next occurrence + (goto-char (next-single-char-property-change current-end 'iedit-occurrence-overlay-name)))) (if (< prev-occurrence-end (point-max)) (push (list prev-occurrence-end (point-max)) unmatched-lines)) (when unmatched-lines diff --git a/iedit-tests.el b/iedit-tests.el index cdba176..12511f7 100644 --- a/iedit-tests.el +++ b/iedit-tests.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2010, 2011, 2012 Victor Ren -;; Time-stamp: <2013-01-19 21:32:53 Victor Ren> +;; Time-stamp: <2013-01-19 22:18:17 Victor Ren> ;; Author: Victor Ren ;; Version: 0.97 ;; X-URL: http://www.emacswiki.org/emacs/Iedit @@ -599,22 +599,33 @@ abcd" "12345678901234567890123456789012345678901234567890..."))) "Test function iedit-hide-unmatched-lines." (with-iedit-test-fixture "foo +foo a - foo + foo bar a a -barfoo +bar foo a a a +bar foo a - foo" +a +a +a + foo bar +a +a +a +a +a +foo" (lambda () - (should (equal (iedit-hide-unmatched-lines 0) nil)) + (should (equal (iedit-hide-unmatched-lines 0) '((64 73) (47 54) (33 38) (21 24) (9 10)))) (iedit-show-all) - (should (equal (iedit-hide-unmatched-lines 1) '((14 29)))) + (should (equal (iedit-hide-unmatched-lines 1) '((66 71) (49 52) (35 36)))) (iedit-show-all) - (should (equal (iedit-hide-unmatched-lines 2) '((6 8)))) + (should (equal (iedit-hide-unmatched-lines 2) '((68 69)) )) (iedit-show-all) (should (equal (iedit-hide-unmatched-lines 3) nil)))))