From 0423394ea121bc1775b474fdf3b5f65b8e6ed0b8 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 3 Aug 2022 12:24:35 +0200 Subject: [PATCH] Fixes bug of removing space before slash command --- packages/web/hooks/slash_command.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/web/hooks/slash_command.ts b/packages/web/hooks/slash_command.ts index 1b0eab0..9051db1 100644 --- a/packages/web/hooks/slash_command.ts +++ b/packages/web/hooks/slash_command.ts @@ -61,6 +61,7 @@ export class SlashCommandHook implements Hook { if (!prefix) { return null; } + const prefixText = prefix.text; let options: Completion[] = []; // No slash commands in comment blocks (queries and such) @@ -76,7 +77,7 @@ export class SlashCommandHook implements Hook { // Delete slash command part this.editor.editorView?.dispatch({ changes: { - from: prefix!.from, + from: prefix!.from + prefixText.indexOf("/"), to: ctx.pos, insert: "", }, @@ -91,7 +92,7 @@ export class SlashCommandHook implements Hook { } return { // + 1 because of the '/' - from: prefix.from + prefix.text.indexOf("/") + 1, + from: prefix.from + prefixText.indexOf("/") + 1, options: options, }; }