1
0

Fixes bug of removing space before slash command

This commit is contained in:
Zef Hemel 2022-08-03 12:24:35 +02:00
parent 1e574a81c3
commit 0423394ea1

View File

@ -61,6 +61,7 @@ export class SlashCommandHook implements Hook<SlashCommandHookT> {
if (!prefix) { if (!prefix) {
return null; return null;
} }
const prefixText = prefix.text;
let options: Completion[] = []; let options: Completion[] = [];
// No slash commands in comment blocks (queries and such) // No slash commands in comment blocks (queries and such)
@ -76,7 +77,7 @@ export class SlashCommandHook implements Hook<SlashCommandHookT> {
// Delete slash command part // Delete slash command part
this.editor.editorView?.dispatch({ this.editor.editorView?.dispatch({
changes: { changes: {
from: prefix!.from, from: prefix!.from + prefixText.indexOf("/"),
to: ctx.pos, to: ctx.pos,
insert: "", insert: "",
}, },
@ -91,7 +92,7 @@ export class SlashCommandHook implements Hook<SlashCommandHookT> {
} }
return { return {
// + 1 because of the '/' // + 1 because of the '/'
from: prefix.from + prefix.text.indexOf("/") + 1, from: prefix.from + prefixText.indexOf("/") + 1,
options: options, options: options,
}; };
} }