howl.ui.Searcher
buffer = nil
editor = Editor Buffer {}
searcher = editor.searcher
cursor = editor.cursor
before_each ->
buffer = Buffer {}
editor.buffer = buffer
after_each -> searcher\cancel!
cancel() moves the cursor back to the original position
buffer.text = 'hello!'
cursor.pos = 1
searcher\forward_to 'll'
searcher\cancel!
assert.equal 1, cursor.pos
next() repeats the last search in the last direction
buffer.text = 'hellö wörld'
cursor.pos = 1
searcher\forward_to 'ö'
searcher\commit!
searcher\next!
assert.equal 8, cursor.pos
.active is true if the searcher is currently active
assert.is_false searcher.active
searcher\forward_to 'o'
assert.is_true searcher.active
searcher\cancel!
assert.is_false searcher.active
forward_to(string)
moves the cursor to the next occurrence of <string>
buffer.text = 'hellö\nworld!'
cursor.pos = 1
searcher\forward_to 'l'
assert.equal 3, cursor.pos
searcher\forward_to 'ld'
assert.equal 10, cursor.pos
highlights the match with "search"
buffer.text = 'hellö\nworld!'
cursor.pos = 1
searcher\forward_to 'lö'
assert.same { 'search' }, highlight.at_pos buffer, 4
assert.same { 'search' }, highlight.at_pos buffer, 5
assert.not_same { 'search' }, highlight.at_pos buffer, 6
skips any matches at the current position by default
buffer.text = 'no means no'
cursor.pos = 1
searcher\forward_to 'no'
assert.equal 10, cursor.pos
does not skip any matches at the current position if the searcher is active
buffer.text = 'sö nö means no'
cursor.pos = 1
searcher\forward_to 'n'
assert.equal 4, cursor.pos
searcher\forward_to 'nö'
assert.equal 4, cursor.pos
does not move the cursor when there is no match
buffer.text = 'hello!'
cursor.pos = 1
searcher\forward_to 'foo'
assert.equal 1, cursor.pos