refactor: reuse filetree selection runtime path

This commit is contained in:
lix-2026
2026-05-25 07:58:32 +08:00
parent 2c3077cb24
commit 6b39454caf
2 changed files with 13 additions and 4 deletions
@@ -5170,13 +5170,10 @@ const SIDEBAR_TREE_JS: &str = r##"
if (!(row instanceof HTMLElement)) return false;
var rowId = row.getAttribute('data-row-id') || '';
if (!rowId) return false;
sidebarFileTreeSelection.selectedRowIds = new Set([rowId]);
sidebarFileTreeSelection.anchorRowId = rowId;
sidebarFileTreeSelection.focusedRowId = rowId;
selectSidebarFileTreeRow(row, { ctrlKey: false, metaKey: false, shiftKey: false });
document.querySelectorAll('#sidebar-file-tree-root .tree-row[data-shell-mode="filetree"][data-active="true"]').forEach(function(activeRow) {
if (activeRow instanceof HTMLElement) activeRow.setAttribute('data-active', 'false');
});
syncSidebarFileTreeSelection();
row.setAttribute('data-active', 'true');
if (options && options.scrollIntoView !== false) {
try {
@@ -11210,6 +11207,13 @@ mod tests {
&& select_body.contains("ctrlKey"),
"inline fallback 必须保留 shift range 与 ctrl/meta toggle"
);
let select_document_body =
js_function_body(SIDEBAR_TREE_JS, "selectSidebarFileTreeDocument");
assert!(
select_document_body
.contains("selectSidebarFileTreeRow(row, { ctrlKey: false, metaKey: false, shiftKey: false })"),
"document selection 应复用 filetree row selection runtime/fallback"
);
}
#[test]