Skip to content

Commit

Permalink
fix: fixed issue with settings when monster had no source
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Jan 21, 2022
1 parent cf2ea78 commit 299f5c7
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/util/suggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,26 +256,28 @@ export class MonsterSuggester extends SuggestionModal<Monster> {

content.nameEl.appendText(item.name[i]);
}
for (
let i = item.name.length;
i < item.name.length + item.source.length;
i++
) {
let match = matches.matches.find((m) => m[0] === i);
if (match) {
content.descEl.createSpan({
cls: "suggestion-highlight",
text: item.source.substring(
match[0] - item.name.length,
match[1] - item.name.length
)
});
if (item.source) {
for (
let i = item.name.length;
i < item.name.length + item.source?.length;
i++
) {
let match = matches.matches.find((m) => m[0] === i);
if (match) {
content.descEl.createSpan({
cls: "suggestion-highlight",
text: item.source.substring(
match[0] - item.name.length,
match[1] - item.name.length
)
});

i += match[1] - match[0] - 1;
continue;
}
i += match[1] - match[0] - 1;
continue;
}

content.descEl.appendText(item.source[i - item.name.length]);
content.descEl.appendText(item.source[i - item.name.length]);
}
}

/* content.setDesc(item.source); */
Expand Down

0 comments on commit 299f5c7

Please sign in to comment.