Permalink
Browse files

Fix the testcase for iedit-hide-unmatched-lines

  • Loading branch information...
1 parent 6e6d4bc commit acb9fa54f3b1d067ebb948cf280f2203d8e65cf0 @victorhge committed Jan 19, 2013
Showing with 25 additions and 15 deletions.
  1. +7 −8 iedit-lib.el
  2. +18 −7 iedit-tests.el
View
@@ -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 <victorhge@gmail.com>
;; 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
View
@@ -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 <victorhge@gmail.com>
;; 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)))))

0 comments on commit acb9fa5

Please sign in to comment.