Skip to content

Latest commit

 

History

History
412 lines (301 loc) · 6.45 KB

search.md

File metadata and controls

412 lines (301 loc) · 6.45 KB

easy

foo bar
  ^ 0

easy search-b

up

  • .search { re: "b" }
foo bar
    ^ 0

1

The quick brown fox
  ^^^ 0
jumps over the
lazy dog quickly.

1 search

up

  • .search { re: "brown" }
The quick brown fox
          ^^^^^ 0
jumps over the
lazy dog quickly.

1 search-repeat

up

  • .search { re: "o", count: 2 }
The quick brown fox
                 ^ 0
jumps over the
lazy dog quickly.

1 search-start

up

  • .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

1 search-start-wrap

up

  • .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.

1 search-wrap

up

  • .search { re: "Th" }
The quick brown fox
^^ 0
jumps over the
lazy dog quickly.

1 search-not-found

up

  • .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.

1 search-backward

up

  • .search { re: "Th", direction: -1 }

Note: Selection always faces forward (except when extending).

The quick brown fox
^^ 0
jumps over the
lazy dog quickly.

1 search-backward-wrap

up

  • .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.

1 search-backward-wrap-other

up

  • .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.

1 search-backward-not-found

up

  • .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.

1 search-extend

up

  • .search { re: "quick", shift: "extend" }
The quick brown fox
  ^ 0
jumps over the
lazy dog quickly.
             ^ 0

1 search-extend-wrap

up

  • .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.

1 search-backward-extend

up

  • .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.

1 search-backward-extend-character

up

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.

1 search-backward-extend-other

up

  • .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.

1 search-backward-extend-character-other

up

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.

1 search-backward-extend-wrap

up

  • .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.

2

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

2 search

up

  • .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

2 search-extend

up

  • .search { re: "o", shift: "extend" }

Same, but extends instead of jumping.

The quick brown fox
jumps over the
lazy dog quickly.
   ^^^^ 0

2 search-extend-character

up

behavior <- character

  • .search { re: "o", shift: "extend" }

Same, but extends instead of jumping.

The quick brown fox
jumps over the
lazy dog quickly.
  ^^^^^ 0

2 search-wrap

up

  • .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.

2 search-extend-wrap

up

  • .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

2 search-backward

up

  • .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.

2 search-backward-extend

up

  • .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

2 search-backward-wrap

up

  • .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

2 search-backward-extend-wrap

up

  • .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