Skip to content

Commit 64b5f89

Browse files
committed
Correct find with whole words on
Correct the find functionality for whole words which was previously returning even if the suffix of a string was matching the word. e.g. "abcdef" would previously match with "def" even when whole word is on.
1 parent a948256 commit 64b5f89

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

client/utils/codemirror-search.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ function parseString(string) {
279279
return string.replace(/\\(.)/g, function (_, ch) {
280280
if (ch == 'n') return '\n';
281281
if (ch == 'r') return '\r';
282+
console.log(ch);
282283
return ch;
283284
});
284285
}
@@ -293,7 +294,7 @@ function parseQuery(query, state) {
293294
query = query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
294295
}
295296
if (state.wholeWord) {
296-
query += '\\b';
297+
query = '\\b' + query + '\\b';
297298
}
298299
}
299300

@@ -305,12 +306,16 @@ function parseQuery(query, state) {
305306
}
306307
// If the resulting regexp will match everything, do not use it
307308
if (regexp.test('')) {
309+
308310
return new RegExp(emptyQuery, 'g');
309311
}
312+
console.log('2->'+ regexp);
310313
return regexp;
314+
311315
}
312316

313317
function startSearch(cm, state, query) {
318+
console.log('startSearch');
314319
state.queryText = query;
315320
state.lastQuery = query;
316321
state.query = parseQuery(query, state);

0 commit comments

Comments
 (0)