mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 13:03:03 +00:00
Finally got the tests running. :-)
This commit is contained in:
parent
de0519e0f0
commit
eda9952fc0
@ -17,8 +17,9 @@ Feature: Mark multiple integration
|
|||||||
When I insert "This text contains the word text twice"
|
When I insert "This text contains the word text twice"
|
||||||
And I select "text"
|
And I select "text"
|
||||||
And I press "C->"
|
And I press "C->"
|
||||||
And I press "C-g"
|
And I switch to multiple-cursors mode
|
||||||
And I type "'"
|
And I type "("
|
||||||
And I press "M-f"
|
And I press "M-f"
|
||||||
And I type "'"
|
And I press "M-f"
|
||||||
Then I should see "This 'text' contains the word 'text' twice"
|
And I type ")"
|
||||||
|
Then I should see "This (text contains) the word (text twice)"
|
||||||
|
@ -5,9 +5,30 @@ Feature: Multiple cursors core
|
|||||||
|
|
||||||
Scenario: Two cursors
|
Scenario: Two cursors
|
||||||
Given there is no region selected
|
Given there is no region selected
|
||||||
When I insert "This text contains the word text thrice (text)"
|
When I insert "This text contains the word text twice"
|
||||||
|
And I select "text"
|
||||||
|
And I press "C->"
|
||||||
|
And I switch to multiple-cursors mode
|
||||||
|
Then I should have 2 cursors
|
||||||
|
|
||||||
|
Scenario: Three cursors
|
||||||
|
Given there is no region selected
|
||||||
|
When I insert:
|
||||||
|
"""
|
||||||
|
This text contains the word text thrice, and
|
||||||
|
one of the instances of the word text is on the second line.
|
||||||
|
"""
|
||||||
And I select "text"
|
And I select "text"
|
||||||
And I press "C->"
|
And I press "C->"
|
||||||
And I press "C->"
|
And I press "C->"
|
||||||
And I press "C-g"
|
And I switch to multiple-cursors mode
|
||||||
Then I should have 3 cursors
|
Then I should have 3 cursors
|
||||||
|
|
||||||
|
Scenario: Exiting multiple-cursors mode with return
|
||||||
|
Given there is no region selected
|
||||||
|
When I insert "This text contains the word text twice"
|
||||||
|
And I select "text"
|
||||||
|
And I press "C->"
|
||||||
|
And I switch to multiple-cursors mode
|
||||||
|
And I press "<return>"
|
||||||
|
Then I should have one cursor
|
||||||
|
@ -1,16 +1,27 @@
|
|||||||
(And "^delete-selection-mode is active$"
|
(And "^delete-selection-mode is active$"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(delete-selection-mode 1)))
|
(delete-selection-mode 1)))
|
||||||
|
|
||||||
(defun is-extra-cursor-p (o)
|
(defun is-extra-cursor-p (o)
|
||||||
(message "overlay-type: %S" (overlay-get o 'type))
|
|
||||||
(eq (overlay-get o 'type) 'additional-cursor))
|
(eq (overlay-get o 'type) 'additional-cursor))
|
||||||
|
|
||||||
(defun num-cursors ()
|
(defun num-cursors ()
|
||||||
(1+ (count-if 'is-extra-cursor-p
|
(1+ (count-if 'is-extra-cursor-p
|
||||||
(overlays-in (point-min) (point-max)))))
|
(overlays-in (point-min) (point-max)))))
|
||||||
|
|
||||||
(Then "^I should have \\([0-9]+\\) cursors$"
|
(Then "^I should have \\([0-9]+\\) cursors$"
|
||||||
(lambda (num)
|
(lambda (num)
|
||||||
(assert (eq (string-to-number num) (num-cursors)) nil
|
(let ((actual (num-cursors)))
|
||||||
"Expected to have %s cursors, but was %d." num (num-cursors))))
|
(assert (eq (string-to-number num) actual) nil
|
||||||
|
"Expected to have %s cursors, but was %d." num actual))))
|
||||||
|
|
||||||
|
(Then "^I should have one cursor$"
|
||||||
|
(lambda ()
|
||||||
|
(assert (not multiple-cursors-mode) nil
|
||||||
|
"Expected to have one cursor, but multiple-cursors-mode is still active.")
|
||||||
|
(assert (eq 1 (num-cursors)) nil
|
||||||
|
"Expected to have one cursor, but there are still fake cursor overlays.")))
|
||||||
|
|
||||||
|
(And "^I switch to multiple-cursors mode$"
|
||||||
|
(lambda ()
|
||||||
|
(mc/switch-from-mark-multiple-to-cursors)))
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
(require 'ert)
|
(require 'ert)
|
||||||
|
|
||||||
(Before
|
(Before
|
||||||
|
(multiple-cursors-mode 0)
|
||||||
(mm/clear-all)
|
(mm/clear-all)
|
||||||
(global-set-key (kbd "C->") 'mark-next-like-this)
|
(global-set-key (kbd "C->") 'mark-next-like-this)
|
||||||
(switch-to-buffer
|
(switch-to-buffer
|
||||||
|
@ -144,7 +144,7 @@ cursors."
|
|||||||
original-command
|
original-command
|
||||||
(get original-command 'mc--unsupported))
|
(get original-command 'mc--unsupported))
|
||||||
(if (not (memq original-command mc--cmds))
|
(if (not (memq original-command mc--cmds))
|
||||||
(when (not (memq original-command mc--cmds-run-once))
|
(when (and original-command (not (memq original-command mc--cmds-run-once)))
|
||||||
(message "Skipping %S" original-command))
|
(message "Skipping %S" original-command))
|
||||||
(mc/execute-command-for-all-fake-cursors original-command))))))
|
(mc/execute-command-for-all-fake-cursors original-command))))))
|
||||||
|
|
||||||
@ -222,12 +222,13 @@ from being executed if in multiple-cursors-mode."
|
|||||||
(overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer)))))))
|
(overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer)))))))
|
||||||
;;----------------------------------------------------------------------------------------
|
;;----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
;; Commands to run only once (not yet in use)
|
;; Commands to run only once (don't need to message about skipping it)
|
||||||
(setq mc--cmds-run-once '(mark-next-like-this
|
(setq mc--cmds-run-once '(mark-next-like-this
|
||||||
save-buffer
|
save-buffer
|
||||||
undo
|
undo
|
||||||
undo-tree-undo
|
undo-tree-undo
|
||||||
undo-tree-redo))
|
undo-tree-redo
|
||||||
|
mc/switch-from-mark-multiple-to-cursors))
|
||||||
|
|
||||||
;; Commands that should be mirrored by all cursors
|
;; Commands that should be mirrored by all cursors
|
||||||
(setq mc--cmds '(mc/keyboard-quit
|
(setq mc--cmds '(mc/keyboard-quit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user