Skip to content

Commit 230cf5d

Browse files
committed
feat: pin the new tab if its dropped before a pinned tab
1 parent 243fca7 commit 230cf5d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/extensionsIntegrated/TabBar/drag-drop.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,26 @@ define(function (require, exports, module) {
328328
CommandManager.execute(Commands.FILE_UNPIN, { file: fileObj, paneId: paneId });
329329
}
330330
}
331+
332+
// if the dragged file is not pinned, we check if it should be pinned,
333+
// if it is dropped before a pinned file
334+
if (!isDraggedFilePinned) {
335+
const newWorkingSet = MainViewManager.getWorkingSet(paneId);
336+
337+
// check if there's a file after this one
338+
if (newPosition < newWorkingSet.length - 1) {
339+
const nextFilePath = newWorkingSet[newPosition + 1].fullPath;
340+
341+
// if the next file is pinned, we pin this file too!
342+
if (MainViewManager.isPathPinned(paneId, nextFilePath)) {
343+
const fileObj = FileSystem.getFileForPath(draggedPath);
344+
345+
// we consciously enable the pin command here, same reason as above
346+
CommandManager.get(Commands.FILE_PIN).setEnabled(true);
347+
CommandManager.execute(Commands.FILE_PIN, { file: fileObj, paneId: paneId });
348+
}
349+
}
350+
}
331351
}
332352
}
333353

0 commit comments

Comments
 (0)