MCPcopy
hub / github.com/philc/vimium / getNextQueryFromRegexMatches

Method getNextQueryFromRegexMatches

content_scripts/mode_find.js:248–272  ·  view source on GitHub ↗
(backwards)

Source from the content-addressed store, hash-verified

246 }
247
248 static getNextQueryFromRegexMatches(backwards) {
249 // find()ing an empty query always returns false
250 if (!this.query.regexMatches?.length) {
251 return "";
252 }
253 const stepSize = backwards ? -1 : 1;
254
255 let [row, col] = this.query.activeRegexIndices;
256 let numRows = this.query.regexMatches.length;
257 col += stepSize;
258 while (col < 0 || col >= this.query.regexMatches[row].length) {
259 if (col < 0) {
260 row += numRows - 1;
261 row %= numRows;
262 col += this.query.regexMatches[row].length;
263 } else {
264 col -= this.query.regexMatches[row].length;
265 row += 1;
266 row %= numRows;
267 }
268 }
269 this.query.activeRegexIndices = [row, col];
270
271 return this.query.regexMatches[row][col];
272 }
273
274 // Returns null if no search has been performed yet.
275 static getQuery(backwards) {

Callers 1

getQueryMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected