MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / updateFileList

Function updateFileList

src/handlers/editorFileTab.js:434–467  ·  view source on GitHub ↗

* Update the position of the file list * @param {HTMLElement} $parent

($parent)

Source from the content-addressed store, hash-verified

432 * @param {HTMLElement} $parent
433 */
434function updateFileList($parent) {
435 const pinnedCount = editorManager.files.filter((file) => file.pinned).length;
436 const children = [...$parent.children];
437 const newFileList = [];
438 for (let el of children) {
439 for (let file of editorManager.files) {
440 if (file.tab === el) {
441 newFileList.push(file);
442 break;
443 }
444 }
445 }
446
447 editorManager.files = newFileList;
448
449 const draggedFile = newFileList.find((file) => file.tab === $tab);
450 if (draggedFile) {
451 const draggedIndex = newFileList.indexOf(draggedFile);
452 let nextPinnedState;
453
454 if (!draggedFile.pinned && draggedIndex < pinnedCount) {
455 nextPinnedState = true;
456 } else if (draggedFile.pinned && draggedIndex >= pinnedCount) {
457 nextPinnedState = false;
458 }
459
460 if (nextPinnedState !== undefined) {
461 draggedFile.setPinnedState(nextPinnedState, { reorder: false });
462 if (typeof editorManager.normalizePinnedTabOrder === "function") {
463 editorManager.normalizePinnedTabOrder(editorManager.files);
464 }
465 }
466 }
467}
468
469/**
470 * Checks if the tab is going to scroll and returns the scroll value

Callers 1

releaseDragFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected