Skip to content

Commit a59b05d

Browse files
committed
Set cursor to insert end when inserting a file or tag in a prompt.
1 parent e5fea80 commit a59b05d

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "quickadd",
33
"name": "QuickAdd",
4-
"version": "0.1.10",
4+
"version": "0.1.11",
55
"minAppVersion": "0.12.00",
66
"description": "Quickly add new pages or content to your vault.",
77
"author": "Christian B. B. Houmann",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quickadd",
3-
"version": "0.1.10",
3+
"version": "0.1.11",
44
"description": "Quickly add new pages or content to your vault.",
55
"main": "main.js",
66
"scripts": {

src/gui/silentFileAndTagSuggester.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,21 @@ export class SilentFileAndTagSuggester extends TextInputSuggest<string> {
5252
const cursorPosition: number = this.inputEl.selectionStart;
5353
const lastInputLength: number = this.lastInput.length;
5454
const currentInputValue: string = this.inputEl.value;
55+
let insertedEndPosition: number = 0;
5556

5657
if (this.lastInputType === TagOrFile.File) {
5758
this.inputEl.value = this.getNewInputValueForFileName(currentInputValue, item, cursorPosition, lastInputLength);
59+
insertedEndPosition = cursorPosition - lastInputLength + item.length + 2;
5860
}
5961

6062
if (this.lastInputType === TagOrFile.Tag) {
6163
this.inputEl.value = this.getNewInputValueForTag(currentInputValue, item, cursorPosition, lastInputLength);
64+
insertedEndPosition = cursorPosition - lastInputLength + item.length - 1;
6265
}
6366

6467
this.inputEl.trigger("input");
6568
this.close();
69+
this.inputEl.setSelectionRange(insertedEndPosition, insertedEndPosition);
6670
}
6771

6872
private getNewInputValueForFileName(currentInputElValue: string, selectedItem: string, cursorPosition: number, lastInputLength: number): string {

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"0.1.10": "0.12.4"
2+
"0.1.11": "0.12.4"
33
}

0 commit comments

Comments
 (0)