From f89d6648f7db06aabaf110937402b58c15a9f4cc Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Tue, 22 Oct 2019 08:49:25 -0400 Subject: [PATCH] Fix incorrect command palette cursor position Fixes #6011 Fixes incorrect command palette cursor position especially on Safari browser. Added additional handling to verify that if no selection is currently present, force the cursor at the end of the input. Inspired by a similar implementation in VS Code. Signed-off-by: Vincent Fugnitto --- packages/monaco/src/browser/monaco-quick-open-service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/monaco/src/browser/monaco-quick-open-service.ts b/packages/monaco/src/browser/monaco-quick-open-service.ts index 353ae323fd264..b2da8594d4d8a 100644 --- a/packages/monaco/src/browser/monaco-quick-open-service.ts +++ b/packages/monaco/src/browser/monaco-quick-open-service.ts @@ -135,6 +135,10 @@ export class MonacoQuickOpenService extends QuickOpenService { const widget = this.widget; if (widget.inputBox) { widget.inputBox.inputElement.tabIndex = 1; + // Position the cursor at the end of the input unless a user has made a selection. + if (widget.inputBox.inputElement.selectionStart === widget.inputBox.inputElement.selectionEnd) { + widget.inputBox.inputElement.selectionStart = widget.inputBox.inputElement.value.length; + } } }