Skip to content

Commit acd5015

Browse files
committed
feat(workingset): switch files on mouse down for faster perceived switching
The file tree and editor tab bar switch files on mouse down, but the working set only switched on mouse up, making it feel slow. Open the file immediately on left-button press (unless the press is on the close icon) and skip the duplicate open in the mouse up drop handler. Right/middle click paths already resolved at mouse down and are unchanged; close via the close icon still happens on mouse up without selecting the file. A drag now makes the pressed item the current file as soon as it is pressed, consistent with dragging tabs in other editors. Claude-Session: https://claude.ai/code/session_018BpQ3Z7w4H2U5qrPGWYRWB
1 parent 84bf98b commit acd5015

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/project/WorkingSetView.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ define(function (require, exports, module) {
309309
offset,
310310
$copy,
311311
$ghost,
312-
draggingCurrentFile;
312+
draggingCurrentFile,
313+
openedOnMouseDown = false;
313314

314315
function initDragging() {
315316
itemHeight = $el.height();
@@ -789,6 +790,10 @@ define(function (require, exports, module) {
789790
.always(function () {
790791
postDropCleanup();
791792
});
793+
} else if (openedOnMouseDown) {
794+
// file was already opened on mouse down for a fast switch feel,
795+
// nothing left to do here
796+
postDropCleanup();
792797
} else {
793798
// Normal right and left click - select the item
794799
FileViewController.setFileViewFocus(FileViewController.WORKING_SET_VIEW);
@@ -864,7 +869,16 @@ define(function (require, exports, module) {
864869
return;
865870
}
866871

867-
872+
// open the file right away on mouse down like the file tree and the
873+
// editor tab bar do, so switching files feels fast instead of waiting
874+
// for mouse up. A drag can still follow - the item just becomes the
875+
// current file as soon as it is pressed.
876+
if (!tryClosing) {
877+
openedOnMouseDown = true;
878+
FileViewController.setFileViewFocus(FileViewController.WORKING_SET_VIEW);
879+
CommandManager.execute(Commands.FILE_OPEN, {fullPath: sourceFile.fullPath,
880+
paneId: sourceView.paneId});
881+
}
868882

869883
e.stopPropagation();
870884
});

0 commit comments

Comments
 (0)