Skip to content

Commit

Permalink
Fix a bug where words containing diacritics are not suggested in "Cur…
Browse files Browse the repository at this point in the history
…rent file complement" and "Current vault complement" when "Match strategy" is set to "prefix," even if "Treat accent diacritics as alphabetic" is enabled (#310)
  • Loading branch information
tadashi-aikawa committed Aug 25, 2024
1 parent 8f163f0 commit d671f45
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
16 changes: 11 additions & 5 deletions src/provider/CurrentFileWordProvider.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { App } from "obsidian";
import { groupBy, uniq } from "../util/collection-helper";
import type { WordsByFirstLetter } from "./suggester";
import type { Tokenizer } from "../tokenizer/tokenizer";
import type { AppHelper } from "../app-helper";
import type { Word } from "../model/Word";
import type { Tokenizer } from "../tokenizer/tokenizer";
import { uniq } from "../util/collection-helper";
import {
allAlphabets,
startsSmallLetterOnlyFirst,
synonymAliases,
} from "../util/strings";
import type { Word } from "../model/Word";
import { pushWord, type WordsByFirstLetter } from "./suggester";

export class CurrentFileWordProvider {
wordsByFirstLetter: WordsByFirstLetter = {};
Expand Down Expand Up @@ -73,7 +73,13 @@ export class CurrentFileWordProvider {
accentsDiacritics: option.makeSynonymAboutAccentsDiacritics,
}),
}));
this.wordsByFirstLetter = groupBy(this.words, (x) => x.value.charAt(0));

for (const word of this.words) {
pushWord(this.wordsByFirstLetter, word.value.charAt(0), word);
word.aliases?.forEach((a) =>
pushWord(this.wordsByFirstLetter, a.charAt(0), word),
);
}
}

clearWords(): void {
Expand Down
12 changes: 8 additions & 4 deletions src/provider/CurrentVaultWordProvider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { App } from "obsidian";
import { groupBy } from "../util/collection-helper";
import type { WordsByFirstLetter } from "./suggester";
import type { Tokenizer } from "../tokenizer/tokenizer";
import type { AppHelper } from "../app-helper";
import type { Word } from "../model/Word";
import type { Tokenizer } from "../tokenizer/tokenizer";
import { dirname } from "../util/path";
import { startsSmallLetterOnlyFirst, synonymAliases } from "../util/strings";
import { pushWord, type WordsByFirstLetter } from "./suggester";

export class CurrentVaultWordProvider {
wordsByFirstLetter: WordsByFirstLetter = {};
Expand Down Expand Up @@ -70,7 +69,12 @@ export class CurrentVaultWordProvider {
}

this.words = Object.values(wordByValue);
this.wordsByFirstLetter = groupBy(this.words, (x) => x.value.charAt(0));
for (const word of this.words) {
pushWord(this.wordsByFirstLetter, word.value.charAt(0), word);
word.aliases?.forEach((a) =>
pushWord(this.wordsByFirstLetter, a.charAt(0), word),
);
}
}

clearWords(): void {
Expand Down

0 comments on commit d671f45

Please sign in to comment.