Fixes bug of removing space before slash command
This commit is contained in:
parent
1e574a81c3
commit
0423394ea1
@ -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,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user