{"record":{"id":"a6ab13e9b38444af","repo":"sxyazi/yazi","slug":"some-files-cannot-be-selected-due-to-path-nesting","errorCode":null,"errorMessage":"Some files cannot be selected, due to path nesting conflict.","messagePattern":"Some files cannot be selected, due to path nesting conflict\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-actor/src/mgr/escape.rs","lineNumber":85,"sourceCode":"\tfn act(cx: &mut Ctx, _: Self::Form) -> Result<Data> {\n\t\tlet tab = cx.tab_mut();\n\n\t\tlet select = tab.mode.is_select();\n\t\tlet Some(indices) = tab.mode.take_visual(tab.current.cursor, tab.current.entries.len()) else {\n\t\t\tsucc!(false)\n\t\t};\n\n\t\trender!();\n\t\tlet files: Vec<_> = indices.into_iter().filter_map(|i| tab.current.entries.get(i)).collect();\n\n\t\tif !select {\n\t\t\ttab.selected.remove_many(files);\n\t\t} else if files.len() != tab.selected.add_many(files) {\n\t\t\tNotifyProxy::push_warn(\n\t\t\t\t\"Escape visual mode\",\n\t\t\t\t\"Some files cannot be selected, due to path nesting conflict.\",\n\t\t\t);\n\t\t\tbail!(\"Some files cannot be selected, due to path nesting conflict.\");\n\t\t}\n\n\t\tsucc!(true)\n\t}\n}\n\n// --- Filter\npub struct EscapeFilter;\n\nimpl Actor for EscapeFilter {\n\ttype Form = VoidForm;\n\n\tconst NAME: &str = \"escape_filter\";\n\n\tfn act(cx: &mut Ctx, _: Self::Form) -> Result<Data> {\n\t\tif cx.current_mut().entries.filter().is_none() {\n\t\t\tsucc!(false);\n\t\t}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/sxyazi/yazi/blob/a541adde4e5b082719a0f21a87eb3eab071ece58/yazi-actor/src/mgr/escape.rs#L67-L103","documentation":"When escaping visual mode with selection, yazi tries to add all visual-mode files to the tab's persistent selection via `add_many`. The selection set rejects entries whose paths are nested inside another selected entry (a file inside an already-selected directory would be selected twice). If some entries could not be added, the actor warns and bails instead of silently producing an inconsistent selection.","triggerScenarios":"Pressing the escape/visual-exit key that runs this actor while the visual selection contains both a directory and files (or subdirectories) nested inside it, so `Selected::add_many` returns a count smaller than `files.len()`.","commonSituations":"User selects a parent directory, then moves the cursor into it and selects children in visual mode, then exits visual mode expecting everything to stay selected; bulk-selection plugins that gather recursive file lists including ancestors.","solutions":["Flatten the selection before exiting visual mode: keep only top-most entries (drop children of already-selected directories)","Handle the bail in your keymap/plugin and notify the user to review the selection","Modify the selection incrementally with `add` checks or pre-filter nested paths before calling the actor"],"exampleFix":"// before\nlet files = dir_and_children; // contains parent + nested children\nact!(mgr:escape_visual, cx, (true, files))?;\n// after\nlet files: Vec<_> = dir_and_children.into_iter()\n    .filter(|f| !dir_and_children.iter().any(|o| o.url != f.url && f.url.starts_with(&o.url)))\n    .collect();\nact!(mgr:escape_visual, cx, (true, files))?;","handlingStrategy":"try-catch","validationCode":"fn has_nested_conflict(files: &[File]) -> bool {\n    files.iter().any(|f| files.iter().any(|o| {\n        o.url != f.url && f.url.starts_with(&o.url)\n    }))\n}","typeGuard":"fn is_safe_selection(files: &[File]) -> bool {\n    !has_nested_conflict(files)\n}","tryCatchPattern":"match escape_visual(cx, files).await {\n    Err(e) if e.to_string().contains(\"path nesting conflict\") => {\n        notify::warn(\"Selection contains a directory and its children; deselect one\");\n    }\n    other => other?,\n}","preventionTips":["Deselect children when a parent directory is selected","Pre-filter nested entries before bulk selection calls","Show the selection list to users before exiting visual mode in scripted flows"],"tags":["selection","state-conflict","yazi"],"backgroundTag":"path-nesting-conflict","analyzedSha":"a541adde4e5b082719a0f21a87eb3eab071ece58","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}