mirror of
https://github.com/fbarrca/obsidian-inlineAI.git
synced 2026-07-22 11:50:24 +00:00
Clean the parsing
This commit is contained in:
parent
f446e63b96
commit
108eb0c251
2 changed files with 6 additions and 8 deletions
|
|
@ -2,11 +2,11 @@ import { SlashCommand } from "./source";
|
|||
|
||||
|
||||
export function parseCommand(userInput: string, prefix: string, customCommands: SlashCommand[]): string {
|
||||
for (const command of customCommands) {
|
||||
const commandPattern = `${prefix}${command.keyword}`;
|
||||
if (userInput.startsWith(commandPattern)) {
|
||||
return userInput.replace(commandPattern, command.prompt).trim();
|
||||
for (const command of customCommands) {
|
||||
const commandPattern = `${prefix}${command.keyword}`;
|
||||
if (userInput.includes(commandPattern)) {
|
||||
return userInput.replace(commandPattern, command.prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return userInput; // Return original text if no command matches
|
||||
return userInput; // Return original text if no command matches
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ function createSlashCommandSource(options: {
|
|||
customCommands: []
|
||||
}) {
|
||||
const { prefix, customCommands } = options;
|
||||
console.log(prefix, customCommands)
|
||||
|
||||
return (context: CompletionContext) => {
|
||||
let word = context.matchBefore(new RegExp(`^\\${prefix}\\w*`))
|
||||
if (!word || (word.from == word.to && !context.explicit))
|
||||
|
|
|
|||
Loading…
Reference in a new issue