Permalink
Browse files

Fix failed test cases

  • Loading branch information...
1 parent 9cfd76f commit 962fcdb6cdff99371d001bf3c335e8725478c9ab @victorhge committed Oct 15, 2012
Showing with 39 additions and 17 deletions.
  1. +24 −5 iedit-tests.el
  2. +15 −12 iedit.el
View
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-08-09 17:17:03 Victor Ren>
+;; Time-stamp: <2012-10-15 16:12:02 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.97
;; X-URL: http://www.emacswiki.org/emacs/Iedit
@@ -30,6 +30,7 @@
;;; Code:
(require 'ert)
(require 'iedit)
+(require 'iedit-rect)
(ert-deftest iedit-compile-test ()
(let ((byte-compile-error-on-warn t ))
@@ -128,6 +129,25 @@ foo"
123foo456123foo456
123foo456")))))
+(ert-deftest iedit-overlay-at-end-of-buffer ()
+ (with-iedit-test-fixture
+ "foo
+foo"
+ (lambda ()
+ (iedit-mode)
+ (highlight-changes-mode 1)
+ (goto-char (point-min))
+ (goto-char (point-at-eol))
+ (iedit-mode)
+ (delete-region (point) (1- (point)))
+ (should (string= (buffer-string)
+ "fo
+fo"))
+ (insert "b")
+ (should (string= (buffer-string)
+ "fob
+fob")))))
+
(ert-deftest iedit-mode-start-from-isearch-test ()
(with-iedit-test-fixture
"foo
@@ -143,7 +163,7 @@ foo"
(isearch-process-search-char ?f)
(isearch-process-search-char ?o)
(isearch-process-search-char ?o)
- (iedit-mode)
+ (iedit-mode-from-isearch)
(should (string= iedit-initial-string-local "foo"))
(should (= 4 (length iedit-occurrences-overlays)))
(iedit-mode)
@@ -342,8 +362,7 @@ foo"
(iedit-mode) ; turn off iedit
(goto-char 2)
(set-mark-command nil)
- (forward-char 1)
- (forward-line 1)
+ (goto-char 7)
(iedit-rectangle-mode)
(iedit-blank-occurrences)
(should (string= (buffer-string) "f o
@@ -463,7 +482,7 @@ arfoo
(should (= 1 (length iedit-occurrences-overlays)))
(iedit-mode)
(goto-char 13)
- (iedit-mode-on-function)
+ (iedit-mode-toggle-on-function)
(should (= 4 (length iedit-occurrences-overlays)))
(iedit-mode)
(iedit-mode)
View
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-09-12 15:22:33 Victor Ren>
+;; Time-stamp: <2012-10-15 15:09:14 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.97
@@ -340,30 +340,32 @@ Keymap used within overlays:
(setq iedit-only-complete-symbol-local complete-symbol)
(setq mark-active nil)
(run-hooks 'deactivate-mark-hook)
+ (setq iedit-initial-string-local occurrence)
(iedit-start (iedit-regexp-quote occurrence) beg end))))
-(defun iedit-mode-from-isearch (regexp)
+(defun iedit-mode-from-isearch ()
"Start Iedit mode using last search string as the regexp."
- (interactive
- (let ((regexp (cond
- ((functionp isearch-word)
- (funcall isearch-word isearch-string))
+ (interactive)
+ (let ((regexp (cond
(isearch-word (word-search-regexp isearch-string))
(isearch-regexp isearch-string)
(t (regexp-quote isearch-string)))))
- (list regexp)))
- (isearch-exit)
- (iedit-start regexp (point-min) (point-max))
+ (if (or isearch-regexp isearch-word)
+ nil
+ (setq iedit-initial-string-local isearch-string))
+ (isearch-exit)
+ (setq mark-active nil)
+ (run-hooks 'deactivate-mark-hook)
+ (iedit-start regexp (point-min) (point-max))
;; TODO: reconsider how to avoid the loop in iedit-same-length
- (if (iedit-same-length)
+ (if (iedit-same-length)
nil
(iedit-done)
- (message "Matches are not the same length.")))
+ (message "Matches are not the same length."))))
(defun iedit-start (occurrence-regexp beg end)
"Start Iedit mode for the `occurrence-regexp' in the current buffer."
(setq iedit-unmatched-lines-invisible iedit-unmatched-lines-invisible-default)
- (setq iedit-initial-string-local occurrence-regexp)
(setq iedit-initial-region (list beg end))
(iedit-start2 occurrence-regexp beg end)
(run-hooks 'iedit-mode-hook)
@@ -401,6 +403,7 @@ the initial string globally."
(iedit-cleanup)
+ (setq iedit-initial-string-local nil)
(setq iedit-mode nil)
(force-mode-line-update)
(remove-hook 'kbd-macro-termination-hook 'iedit-done t)

0 comments on commit 962fcdb

Please sign in to comment.