Skip to content

Commit 4145304

Browse files
committed
rename suggestions: fix not showing preview when input box is empty but a rename suggestion is focused
1 parent 9f4d6cf commit 4145304

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/vs/editor/contrib/rename/browser/renameInputField.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,10 @@ export class RenameInputField implements IContentWidget {
298298
assertType(this._input !== undefined);
299299
assertType(this._candidatesView !== undefined);
300300

301-
const candidateName = this._candidatesView.focusedCandidate;
302-
if ((candidateName === undefined && this._input.value === value) || this._input.value.trim().length === 0) {
303-
this.cancelInput(true, '_currentAcceptInput (because candidateName is undefined or input.value is empty)');
301+
const newName = this._candidatesView.focusedCandidate ?? this._input.value;
302+
303+
if (newName === value || newName.trim().length === 0 /* is just whitespace */) {
304+
this.cancelInput(true, '_currentAcceptInput (because newName === value || newName.trim().length === 0)');
304305
return;
305306
}
306307

@@ -309,7 +310,7 @@ export class RenameInputField implements IContentWidget {
309310
this._candidatesView.clearCandidates();
310311

311312
resolve({
312-
newName: candidateName ?? this._input.value,
313+
newName,
313314
wantsPreview: supportPreview && wantsPreview
314315
});
315316
};

0 commit comments

Comments
 (0)