Skip to content

Commit

Permalink
fix(obsidian/suggester): fix chs support for citation editor suggester
Browse files Browse the repository at this point in the history
also support `【` as suggester trigger

close #222
  • Loading branch information
aidenlx committed Nov 1, 2023
1 parent 81ff9f0 commit efbd022
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/obsidian/src/note-feature/citation-suggest/editor.ts
Expand Up @@ -30,19 +30,19 @@ export class CitationEditorSuggest extends ZoteroItemEditorSuggest {
if (!this.plugin.settings.current?.citationEditorSuggester) return null;
const line = editor.getLine(cursor.line),
sub = line.substring(0, cursor.ch);
const match = sub.match(/\[@([\w\- ]*)\/?$/);
const match = sub.match(/[[【]@([^\]】]*)$/);
if (!match) return null;
const end = { ...cursor };
// if `]` is next to cursor (auto-complete), include it to replace range as well
if (line[cursor.ch] === "]") end.ch += 1;
if (line[cursor.ch] === "]" || line[cursor.ch] === "】") end.ch += 1;
return {
end,
start: {
ch: match.index as number,
line: cursor.line,
alt: Boolean(match[0]?.endsWith("/")),
} as EditorPositionWithAlt,
query: match[1],
query: match[1].replaceAll(/\/$/g, ""),
};
}

Expand Down

0 comments on commit efbd022

Please sign in to comment.