mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 21:03:05 +00:00
Add more core tests.
This commit is contained in:
parent
4a7fb327f5
commit
50851e7ac2
@ -3,23 +3,23 @@ Feature: Mark multiple integration
|
|||||||
As an Emacs user with mark-multiple
|
As an Emacs user with mark-multiple
|
||||||
I want to mark multiple regions and then go to multiple-cursors-mode
|
I want to mark multiple regions and then go to multiple-cursors-mode
|
||||||
|
|
||||||
Scenario: Mark two words and change them
|
Scenario: Two cursors
|
||||||
Given there is no region selected
|
Given there is no region selected
|
||||||
And delete-selection-mode is active
|
|
||||||
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 type "sentence"
|
And I press "C-g"
|
||||||
Then I should see "This sentence contains the word sentence twice"
|
Then I should have 2 cursors
|
||||||
|
|
||||||
Scenario: Mark two words and go to multiple cursors
|
Scenario: Three cursors
|
||||||
Given there is no region selected
|
Given there is no region selected
|
||||||
When I insert "This text contains the word text twice"
|
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 switch to multiple-cursors mode
|
And I press "C->"
|
||||||
And I type "("
|
And I press "C-g"
|
||||||
And I press "M-f"
|
Then I should have 3 cursors
|
||||||
And I press "M-f"
|
|
||||||
And I type ")"
|
|
||||||
Then I should see "This (text contains) the word (text twice)"
|
|
||||||
|
@ -3,32 +3,80 @@ Feature: Multiple cursors core
|
|||||||
As an Emacs user with multiple-cursors
|
As an Emacs user with multiple-cursors
|
||||||
I want to change multiple parts of the buffer at once
|
I want to change multiple parts of the buffer at once
|
||||||
|
|
||||||
Scenario: Two cursors
|
|
||||||
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
|
|
||||||
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 press "C->"
|
|
||||||
And I press "C->"
|
|
||||||
And I switch to multiple-cursors mode
|
|
||||||
Then I should have 3 cursors
|
|
||||||
|
|
||||||
Scenario: Exiting multiple-cursors mode with return
|
Scenario: Exiting multiple-cursors mode with return
|
||||||
Given there is no region selected
|
Given there is no region selected
|
||||||
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 switch to multiple-cursors mode
|
And I press "C-g"
|
||||||
And I press "<return>"
|
And I press "<return>"
|
||||||
Then I should have one cursor
|
Then I should have one cursor
|
||||||
|
|
||||||
|
Scenario: Exiting multiple-cursors mode with C-g
|
||||||
|
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 press "C-g"
|
||||||
|
And I press "C-g"
|
||||||
|
Then I should have one cursor
|
||||||
|
|
||||||
|
Scenario: Separate kill-rings
|
||||||
|
Given I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
When I press "M-f"
|
||||||
|
And I press "M-d"
|
||||||
|
And I press "M-b"
|
||||||
|
And I press "C-y"
|
||||||
|
Then I should see "This containstext the word twicetext"
|
||||||
|
|
||||||
|
Scenario: Separate kill-rings, yank-pop
|
||||||
|
Given I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
When I press "M-d"
|
||||||
|
And I press "C-f"
|
||||||
|
And I press "M-d"
|
||||||
|
And I press "C-y M-y"
|
||||||
|
Then I should see "This text the word text"
|
||||||
|
|
||||||
|
Scenario: Interprogram paste
|
||||||
|
Given I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
When I copy "external" in another program
|
||||||
|
And I press "C-y"
|
||||||
|
Then I should see "This externaltext contains the word externaltext twice"
|
||||||
|
|
||||||
|
Scenario: Multiple lambdas
|
||||||
|
Given I have bound C-! to a lambda that inserts "a"
|
||||||
|
And I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
When I press "C-!"
|
||||||
|
Then I should see "This atext contains the word atext twice"
|
||||||
|
|
||||||
|
Scenario: Multiple supported command (forward-word in this case)
|
||||||
|
Given I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
And I type "("
|
||||||
|
And I press "M-f"
|
||||||
|
And I press "M-f"
|
||||||
|
And I type ")"
|
||||||
|
Then I should see "This (text contains) the word (text twice)"
|
||||||
|
|
||||||
|
Scenario: Setting and popping mark
|
||||||
|
Given I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
And I press "C-SPC"
|
||||||
|
And I press "M-f"
|
||||||
|
And I press "C-u C-SPC"
|
||||||
|
And I type "!"
|
||||||
|
Then I should see "This !text contains the word !text twice"
|
||||||
|
|
||||||
|
Scenario: delete-selection-mode (self-insert-command)
|
||||||
|
Given I turn on delete-selection-mode
|
||||||
|
And I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
And I press "C-SPC"
|
||||||
|
And I press "M-f"
|
||||||
|
And I type "!"
|
||||||
|
Then I should see "This ! contains the word ! twice"
|
||||||
|
|
||||||
|
Scenario: delete-selection-mode (delete-char)
|
||||||
|
Given I turn on delete-selection-mode
|
||||||
|
And I have cursors at "text" in "This text contains the word text twice"
|
||||||
|
And I press "C-SPC"
|
||||||
|
And I press "M-f"
|
||||||
|
And I press "C-d"
|
||||||
|
Then I should see "This contains the word twice"
|
||||||
|
@ -22,6 +22,33 @@
|
|||||||
(assert (eq 1 (num-cursors)) nil
|
(assert (eq 1 (num-cursors)) nil
|
||||||
"Expected to have one cursor, but there are still fake cursor overlays.")))
|
"Expected to have one cursor, but there are still fake cursor overlays.")))
|
||||||
|
|
||||||
(And "^I switch to multiple-cursors mode$"
|
(When "^I press \"\\(.+\\)\"$"
|
||||||
(lambda ()
|
(lambda (keybinding)
|
||||||
(mc/switch-from-mark-multiple-to-cursors)))
|
(let ((macro (edmacro-parse-keys keybinding)))
|
||||||
|
(if espuds-chain-active
|
||||||
|
(setq espuds-action-chain (vconcat espuds-action-chain macro))
|
||||||
|
(if (and (equal keybinding "C-g")
|
||||||
|
(eq (key-binding (kbd "C-g")) 'keyboard-quit))
|
||||||
|
(espuds-quit)
|
||||||
|
(execute-kbd-macro macro))))))
|
||||||
|
|
||||||
|
(Given "^I have cursors at \"\\(.+\\)\" in \"\\(.+\\)\"$"
|
||||||
|
(lambda (needle haystack)
|
||||||
|
(insert haystack)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(search-forward needle)
|
||||||
|
(set-mark (point))
|
||||||
|
(goto-char (match-beginning 0))
|
||||||
|
(mark-all-like-this)
|
||||||
|
(mc/switch-from-mark-multiple-to-cursors)))
|
||||||
|
|
||||||
|
(When "^I copy \"\\(.+\\)\" in another program$"
|
||||||
|
(lambda (text)
|
||||||
|
(lexical-let ((text text))
|
||||||
|
(setq interprogram-paste-function
|
||||||
|
#'(lambda () (let ((r text)) (setq text nil) r))))))
|
||||||
|
|
||||||
|
(Given "^I have bound C-! to a lambda that inserts \"\\(.+\\)\"$"
|
||||||
|
(lambda (ins)
|
||||||
|
(lexical-let ((ins ins))
|
||||||
|
(global-set-key (kbd "C-!") #'(lambda () (interactive) (insert ins))))))
|
||||||
|
@ -228,6 +228,8 @@ from being executed if in multiple-cursors-mode."
|
|||||||
undo
|
undo
|
||||||
undo-tree-undo
|
undo-tree-undo
|
||||||
undo-tree-redo
|
undo-tree-redo
|
||||||
|
universal-argument
|
||||||
|
universal-argument-other-key
|
||||||
mc/switch-from-mark-multiple-to-cursors))
|
mc/switch-from-mark-multiple-to-cursors))
|
||||||
|
|
||||||
;; Commands that should be mirrored by all cursors
|
;; Commands that should be mirrored by all cursors
|
||||||
|
Loading…
x
Reference in New Issue
Block a user