Skip to content

Commit a575592

Browse files
authored
Support toggleable selection during rename (microsoft#158190)
* Support toggleable selection during rename * Don't select the dot
1 parent 0ddc2d1 commit a575592

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/vs/workbench/contrib/files/browser/views/explorerViewer.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
483483
const styler = attachInputBoxStyler(inputBox, this.themeService);
484484

485485
const lastDot = value.lastIndexOf('.');
486+
let currentSelectionState = 'prefix';
486487

487488
inputBox.value = value;
488489
inputBox.focus();
@@ -520,7 +521,22 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
520521
label.setFile(joinPath(parent, value || ' '), labelOptions); // update label icon while typing!
521522
}),
522523
DOM.addStandardDisposableListener(inputBox.inputElement, DOM.EventType.KEY_DOWN, (e: IKeyboardEvent) => {
523-
if (e.equals(KeyCode.Enter)) {
524+
if (e.equals(KeyCode.F2)) {
525+
const dotIndex = inputBox.value.lastIndexOf('.');
526+
if (stat.isDirectory || dotIndex === -1) {
527+
return;
528+
}
529+
if (currentSelectionState === 'prefix') {
530+
currentSelectionState = 'all';
531+
inputBox.select({ start: 0, end: inputBox.value.length });
532+
} else if (currentSelectionState === 'all') {
533+
currentSelectionState = 'suffix';
534+
inputBox.select({ start: dotIndex + 1, end: inputBox.value.length });
535+
} else {
536+
currentSelectionState = 'prefix';
537+
inputBox.select({ start: 0, end: dotIndex });
538+
}
539+
} else if (e.equals(KeyCode.Enter)) {
524540
if (!inputBox.validate()) {
525541
done(true, true);
526542
}

0 commit comments

Comments
 (0)