Skip to content

Commit

Permalink
Fix the testcase for iedit-hide-unmatched-lines
Browse files Browse the repository at this point in the history
  • Loading branch information
victorhge committed Jan 19, 2013
1 parent 6e6d4bc commit acb9fa5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
15 changes: 7 additions & 8 deletions iedit-lib.el
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
25 changes: 18 additions & 7 deletions iedit-tests.el
Expand Up @@ -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
Expand Down Expand Up @@ -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)))))

Expand Down

0 comments on commit acb9fa5

Please sign in to comment.