From 5cceb7f6b5af3dc59044838c26abdab70f303742 Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Fri, 19 Apr 2019 17:04:56 -0500 Subject: [PATCH 1/2] Prevent explorer element edition from ending between rendering calls. Fixes #72626 --- .../files/browser/views/explorerViewer.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index 18300e1418be3..709a6519bcf31 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -218,20 +218,22 @@ export class FilesRenderer implements ITreeRenderer 0 && !stat.isDirectory ? lastDot : value.length }); - const done = once(async (success: boolean) => { + const done = once(async (success: boolean, fromDOMEvent: boolean) => { label.element.style.display = 'none'; const value = inputBox.value; dispose(toDispose); container.removeChild(label.element); - // Timeout: once done rendering only then re-render #70902 - setTimeout(() => editableData.onFinish(value, success), 0); + if (fromDOMEvent) { + // Timeout: once done rendering only then re-render #70902 + setTimeout(() => editableData.onFinish(value, success), 0); + } }); let ignoreDisposeAndBlur = true; setTimeout(() => ignoreDisposeAndBlur = false, 100); const blurDisposable = DOM.addDisposableListener(inputBox.inputElement, DOM.EventType.BLUR, () => { if (!ignoreDisposeAndBlur) { - done(inputBox.isInputValid()); + done(inputBox.isInputValid(), true); } }); @@ -240,10 +242,10 @@ export class FilesRenderer implements ITreeRenderer { if (e.equals(KeyCode.Enter)) { if (inputBox.validate()) { - done(true); + done(true, true); } } else if (e.equals(KeyCode.Escape)) { - done(false); + done(false, true); } }), blurDisposable, @@ -252,10 +254,8 @@ export class FilesRenderer implements ITreeRenderer { - if (!ignoreDisposeAndBlur) { - blurDisposable.dispose(); - done(false); - } + blurDisposable.dispose(); + done(false, false); }); } From b96b0c0450ccc435d3ee58fc3e478cdb79dd3663 Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Sat, 27 Apr 2019 14:27:17 -0500 Subject: [PATCH 2/2] Rename parameter --- .../workbench/contrib/files/browser/views/explorerViewer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index 709a6519bcf31..ebf06281d3264 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -218,12 +218,12 @@ export class FilesRenderer implements ITreeRenderer 0 && !stat.isDirectory ? lastDot : value.length }); - const done = once(async (success: boolean, fromDOMEvent: boolean) => { + const done = once(async (success: boolean, finishEditing: boolean) => { label.element.style.display = 'none'; const value = inputBox.value; dispose(toDispose); container.removeChild(label.element); - if (fromDOMEvent) { + if (finishEditing) { // Timeout: once done rendering only then re-render #70902 setTimeout(() => editableData.onFinish(value, success), 0); }