Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't expand parent element if it's the root in single folder workspace when editing an element in explorer. #72627

Merged
merged 2 commits into from
May 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, finishEditing: 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 (finishEditing) {
// 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