132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/textbringer/commands/isearch.rb', line 132
def isearch_search
forward = ISEARCH_STATUS[:forward]
options = if /\A[A-Z]/.match?(ISEARCH_STATUS[:string])
nil
else
Regexp::IGNORECASE
end
re = Regexp.new(Regexp.quote(ISEARCH_STATUS[:string]), options)
last_pos = ISEARCH_STATUS[:last_pos]
if forward
offset = last_pos
else
Buffer.current.save_excursion do
pos = last_pos - ISEARCH_STATUS[:string].bytesize
goto_char(last_pos)
while Buffer.current.point > pos
backward_char
end
offset = Buffer.current.point
end
end
if offset >= 0 && Buffer.current.byteindex(forward, re, offset)
if Buffer.current != Buffer.minibuffer
message(isearch_prompt + ISEARCH_STATUS[:string], log: false)
end
Buffer.current.set_visible_mark(forward ? match_beginning(0) :
match_end(0))
goto_char(forward ? match_end(0) : match_beginning(0))
else
if Buffer.current != Buffer.minibuffer
message("Failing " + isearch_prompt + ISEARCH_STATUS[:string],
log: false)
end
end
end
|