fix(editor): keep cursor at end of inserted completion text (#1136)
Thanks @dbin0123!
This commit is contained in:
1 parent
2d1d40f6ab
commit
2ef29c004a
1 file changed
+10
-2
@@ -868,7 +868,11 @@ function completionOptionForItem(item: QueryCompletionItem) {
|
||||
if (typeof originalApply === "function") {
|
||||
originalApply(view, completionItem as never, from, to);
|
||||
} else {
|
||||
view.dispatch({ changes: { from, to, insert: String(originalApply ?? item.label) } });
|
||||
const insert = String(originalApply ?? item.label);
|
||||
view.dispatch({
|
||||
changes: { from, to, insert },
|
||||
selection: { anchor: from + insert.length },
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -881,7 +885,11 @@ function completionOptionForItem(item: QueryCompletionItem) {
|
||||
boost: item.boost,
|
||||
apply(view: EditorViewType, _completionItem: unknown, from: number, to: number) {
|
||||
record();
|
||||
view.dispatch({ changes: { from, to, insert: item.apply ?? item.label } });
|
||||
const insert = item.apply ?? item.label;
|
||||
view.dispatch({
|
||||
changes: { from, to, insert },
|
||||
selection: { anchor: from + insert.length },
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user