foo bar
^ 0
- .search { re: "b" }
foo bar
^ 0
The quick brown fox
^^^ 0
jumps over the
lazy dog quickly.
- .search { re: "brown" }
The quick brown fox
^^^^^ 0
jumps over the
lazy dog quickly.
- .search { re: "o", count: 2 }
The quick brown fox
^ 0
jumps over the
lazy dog quickly.
- .search { re: "quick" }
Search starts after the selection so the first "quick" is not matched.
The quick brown fox
jumps over the
lazy dog quickly.
^^^^^ 0
- .search { re: "quick " }
Search starts after the selection, but wraps over to find "quick ".
The quick brown fox
^^^^^^ 0
jumps over the
lazy dog quickly.
- .search { re: "Th" }
The quick brown fox
^^ 0
jumps over the
lazy dog quickly.
- .search { re: "pig", $expect: /^no selections remain$/ }
No matches found. Selection is left untouched because otherwise there would be no selection left.
The quick brown fox
^^^ 0
jumps over the
lazy dog quickly.
- .search { re: "Th", direction: -1 }
Note: Selection always faces forward (except when extending).
The quick brown fox
^^ 0
jumps over the
lazy dog quickly.
- .search { re: "he", direction: -1 }
Search starts before the selection and wraps around to find the last "he".
The quick brown fox
jumps over the
^^ 0
lazy dog quickly.
- .search { re: "he q", direction: -1 }
Search starts before the selection "q" but wraps around to find "he q".
The quick brown fox
^^^^ 0
jumps over the
lazy dog quickly.
- .search { re: "pig", direction: -1, $expect: /^no selections remain$/ }
No matches found. Selection is left untouched because otherwise there would be no selection left.
The quick brown fox
^^^ 0
jumps over the
lazy dog quickly.
- .search { re: "quick", shift: "extend" }
The quick brown fox
^ 0
jumps over the
lazy dog quickly.
^ 0
- .search { re: "T", shift: "extend", $expect: /^no selections remain$/ }
When extending, a selection is deleted if it would require wrapping to find the next match. In this case, the (only) main selection is left untouched because otherwise there would be no selection left.
The quick brown fox
^^^ 0
jumps over the
lazy dog quickly.
- .search { re: "T", direction: -1, shift: "extend" }
When extending, the resulting selection may face backward.
The quick brown fox
|^ 0
jumps over the
lazy dog quickly.
behavior <- character
- .search { re: "T", direction: -1, shift: "extend" }
Note: "e" is included in character-selections because it is the anchor.
The quick brown fox
|^^ 0
jumps over the
lazy dog quickly.
- .search { re: "Th", direction: -1, shift: "extend" }
When extending, the resulting selection may face backward.
The quick brown fox
|^ 0
jumps over the
lazy dog quickly.
behavior <- character
- .search { re: "Th", direction: -1, shift: "extend" }
Note: "e" is included in character-selections because it is the anchor.
The quick brown fox
|^^ 0
jumps over the
lazy dog quickly.
- .search { re: "lazy", direction: -1, shift: "extend", $expect: /^no selections remain$/ }
When extending, a selection is deleted if it would require wrapping to find the next match. In this case, the (only) main selection is left untouched because otherwise there would be no selection left.
The quick brown fox
^^^ 0
jumps over the
lazy dog quickly.
Remember that the search will start at the start or end of the selection, so anything that is (partially) covered by the current selection cannot be found without wrapping first. The following cases show some consequences.
The quick brown fox
| 0
jumps over the
lazy dog quickly.
^ 0
- .search { re: "o" }
Forward search starts at "y" and finds "dog" instead of "brown".
The quick brown fox
jumps over the
lazy dog quickly.
^ 0
- .search { re: "o", shift: "extend" }
Same, but extends instead of jumping.
The quick brown fox
jumps over the
lazy dog quickly.
^^^^ 0
behavior <- character
- .search { re: "o", shift: "extend" }
Same, but extends instead of jumping.
The quick brown fox
jumps over the
lazy dog quickly.
^^^^^ 0
- .search { re: "he" }
Forward search starts at "y" and wraps to "The" instead of "the".
The quick brown fox
|^ 0
jumps over the
lazy dog quickly.
- .search { re: "he", shift: "extend", $expect: /^no selections remain$/ }
When extending, Dance should not wrap around document edges to find "The". "the" is not considered at all. No-op due to no selections remaining.
The quick brown fox
| 0
jumps over the
lazy dog quickly.
^ 0
- .search { re: "u", direction: -1 }
Backward search starts at "b" and finds "quick" instead of "jumps".
The quick brown fox
^ 0
jumps over the
lazy dog quickly.
- .search { re: "u", direction: -1, shift: "extend" }
Same, but extends instead of jumping.
The quick brown fox
| 0
jumps over the
lazy dog quickly.
^ 0
- .search { re: "o", direction: -1 }
Backward search starts at "b" and wraps to "dog" instead of "brown".
The quick brown fox
jumps over the
lazy dog quickly.
^ 0
- .search { re: "o", direction: -1, shift: "extend", $expect: /^no selections remain$/ }
When extending, Dance should not wrap around document edges to find "dog". "brown" is not considered at all. No-op due to no selections remaining.
The quick brown fox
| 0
jumps over the
lazy dog quickly.
^ 0