Skip to content

Commit

Permalink
Prevent explorer element edition from ending between rendering calls. F…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 committed Apr 27, 2019
1 parent 750680d commit 5cceb7f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,22 @@ export class FilesRenderer implements ITreeRenderer<ExplorerItem, FuzzyScore, IF
inputBox.focus();
inputBox.select({ start: 0, end: lastDot > 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);
}
});

Expand All @@ -240,10 +242,10 @@ export class FilesRenderer implements ITreeRenderer<ExplorerItem, FuzzyScore, IF
DOM.addStandardDisposableListener(inputBox.inputElement, DOM.EventType.KEY_DOWN, (e: IKeyboardEvent) => {
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,
Expand All @@ -252,10 +254,8 @@ export class FilesRenderer implements ITreeRenderer<ExplorerItem, FuzzyScore, IF
];

return toDisposable(() => {
if (!ignoreDisposeAndBlur) {
blurDisposable.dispose();
done(false);
}
blurDisposable.dispose();
done(false, false);
});
}

Expand Down

0 comments on commit 5cceb7f

Please sign in to comment.