Simplifies note prompt selection and timestamp formatting

Refactors cursor handling to use setCursor instead of setSelection when collapsing selections

Improves timestamp generation by using environment's default locale automatically instead of manually specifying language

Enhances code clarity and simplifies locale handling for timestamp formatting
This commit is contained in:
AlexKucera committed 2025-10-25 10:48:02 +02:00
1 parent 2b9c8fbc5b
commit fca191b850
1 file changed
+3 -4
+3 -4
View File
@@ -98,7 +98,7 @@ export class NotePromptsCommand {
const to = editor.getCursor('to'); const to = editor.getCursor('to');
const hasSelection = from.line !== to.line || from.ch !== to.ch; const hasSelection = from.line !== to.line || from.ch !== to.ch;
if (hasSelection) { if (hasSelection) {
editor.setSelection(from, from); editor.setCursor(from);
} }
const cursor = editor.getCursor(); // refreshed after collapse const cursor = editor.getCursor(); // refreshed after collapse
const currentLine = editor.getLine(cursor.line) ?? ''; const currentLine = editor.getLine(cursor.line) ?? '';
@@ -146,9 +146,8 @@ export class NotePromptsCommand {
* @returns Formatted markdown string ready for insertion * @returns Formatted markdown string ready for insertion
*/ */
private formatPrompts(prompts: string[]): string { private formatPrompts(prompts: string[]): string {
// Use user's locale for timestamp formatting to respect regional preferences // Let Intl pick the default environment locale automatically
const locale = navigator?.language ?? 'en-US'; const timestamp = new Intl.DateTimeFormat(undefined, {
const timestamp = new Intl.DateTimeFormat(locale, {
year: 'numeric', year: 'numeric',
month: 'short', month: 'short',
day: 'numeric', day: 'numeric',