diff --git a/features/hide-unmatched-lines.feature b/features/hide-unmatched-lines.feature new file mode 100644 index 0000000..3a4040e --- /dev/null +++ b/features/hide-unmatched-lines.feature @@ -0,0 +1,73 @@ +Feature: Hiding lines without cursor + + Scenario: Hiding lines when three cursor active + Given I have cursors at "line" in : + """ + 0 + line + 2 + 3 + line + 5 + 6 + 7 + 8 + 9 + 10 + 11 + line + 13 + 14 + 15 + """ + And I press "C-'" + Then I should have 3 cursors + Then I should see exactly: + """ + 0 + line + 2 + 3 + line + 5 + 6 + + 10 + 11 + line + 13 + 14 + + """ + + + Scenario: Hiding lines when only two cursor active + When I insert: + """ + 1 + 2 + 3 + 4 + 5 + text + 6 + 7 + 8 + 9 + 10 + """ + And I go to the front of the word "text" + And I press "C->" + And I press "C-'" + Then I should have 2 cursors + Then I should see exactly: + """ + + 4 + 5 + text + 6 + 7 + 8 + + """ diff --git a/features/step-definitions/multiple-cursors-steps.el b/features/step-definitions/multiple-cursors-steps.el index a0052fd..a5590b7 100644 --- a/features/step-definitions/multiple-cursors-steps.el +++ b/features/step-definitions/multiple-cursors-steps.el @@ -79,6 +79,17 @@ (mc/mark-all-like-this) (mc/keyboard-quit))) +(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)) + (mc/mark-all-like-this) + (mc/keyboard-quit))) + + (When "^I copy \"\\(.+\\)\" in another program$" (lambda (text) (lexical-let ((text text)) @@ -137,3 +148,19 @@ (split-string rest)) "-")))) (call-interactively func)))) + +(Then "^I should see exactly\\(?: \"\\(.+\\)\"\\|:\\)$" + "Asserts that the current buffer does not include some text with + respect of text hidden by overlays" + (lambda (expected) + (let ((p (point-min)) + (visible-text "") + (message "Expected '%s' to be part of '%s', but was not found in current buffer.") + ) + (while (not (= p (point-max))) + (if (not (invisible-p p)) + (setq visible-text (concat visible-text (buffer-substring p (1+ p)))) + ) + (setq p (1+ p)) + ) + (cl-assert (s-equals? expected visible-text) nil message expected visible-text))))