mirror of https://github.com/zulip/zulip.git
typeahead_helper: Fix TypeScript noUncheckedIndexedAccess errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
d0a03be8e0
commit
83eb0a326a
|
@ -58,8 +58,7 @@ export function highlight_with_escaping_and_regex(regex: RegExp, item: string):
|
||||||
const pieces = item.split(regex).filter(Boolean);
|
const pieces = item.split(regex).filter(Boolean);
|
||||||
let result = "";
|
let result = "";
|
||||||
|
|
||||||
for (let i = 0; i < pieces.length; i += 1) {
|
for (const [i, piece] of pieces.entries()) {
|
||||||
const piece = pieces[i];
|
|
||||||
if (regex.test(piece) && (i === 0 || pieces[i - 1].endsWith(" "))) {
|
if (regex.test(piece) && (i === 0 || pieces[i - 1].endsWith(" "))) {
|
||||||
// only highlight if the matching part is a word prefix, ie
|
// only highlight if the matching part is a word prefix, ie
|
||||||
// if it is the 1st piece or if there was a space before it
|
// if it is the 1st piece or if there was a space before it
|
||||||
|
|
Loading…
Reference in New Issue