{"record":{"id":"44e9aa04541e4a44","repo":"helix-editor/helix","slug":"can-only-set-a-split-once-of-a-specific-type","errorCode":null,"errorMessage":"can only set a split once of a specific type","messagePattern":"can only set a split once of a specific type","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"helix-term/src/args.rs","lineNumber":54,"sourceCode":"            let filename = helix_stdx::path::canonicalize(filename);\n\n            args.files\n                .entry(filename)\n                .and_modify(|positions| positions.push(position))\n                .or_insert_with(|| vec![position]);\n        };\n\n        argv.next(); // skip the program, we don't care about that\n\n        while let Some(arg) = argv.next() {\n            match arg.as_str() {\n                \"--\" => break, // stop parsing at this point treat the remaining as files\n                \"--version\" => args.display_version = true,\n                \"--help\" => args.display_help = true,\n                \"--strict\" => args.strict = true,\n                \"--tutor\" => args.load_tutor = true,\n                \"--vsplit\" => match args.split {\n                    Some(_) => anyhow::bail!(\"can only set a split once of a specific type\"),\n                    None => args.split = Some(Layout::Vertical),\n                },\n                \"--hsplit\" => match args.split {\n                    Some(_) => anyhow::bail!(\"can only set a split once of a specific type\"),\n                    None => args.split = Some(Layout::Horizontal),\n                },\n                \"--health\" => {\n                    args.health = true;\n                    args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));\n                }\n                \"-g\" | \"--grammar\" => match argv.next().as_deref() {\n                    Some(\"fetch\") => args.fetch_grammars = true,\n                    Some(\"build\") => args.build_grammars = true,\n                    _ => {\n                        anyhow::bail!(\"--grammar must be followed by either 'fetch' or 'build'\")\n                    }\n                },\n                \"-c\" | \"--config\" => match argv.next().as_deref() {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-term/src/args.rs#L36-L72","documentation":"Argument parser rejects setting a vertical split layout when args.split is already Some(...): '--vsplit' is only accepted while no split direction has been set. The bail fires on the second/duplicate '--vsplit' or on '--vsplit' after '--hsplit'.","triggerScenarios":"Command line contains '--vsplit' twice, or '--vsplit' after '--hsplit' (which already set args.split = Some(Horizontal)).","commonSituations":"Shell aliases or scripts appending both flags ('hx --vsplit --hsplit file' intending one of each); copy-pasted command lines accumulating flags; misunderstanding that the flags apply to ALL opened files, so only one direction can be chosen.","solutions":["Keep exactly one split flag: either --vsplit or --hsplit, once","Fix the alias/script that concatenates both flags","To mix layouts, open the first file with a split flag and split further files interactively (spacebar menu) inside the editor"],"exampleFix":"# before\nhx --vsplit --hsplit a.txt b.txt\n\n# after\nhx --vsplit a.txt b.txt","handlingStrategy":"validation","validationCode":"# Deduplicate split flags before invoking hx:\nargs=$(printf '%s\\n' \"$@\" | grep -E -- '--vsplit|--hsplit' | sort -u | head -1)\n# then pass $args once, followed by files","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep exactly one split flag per invocation","Audit shell aliases that append layout flags unconditionally","Remember the flag applies to every file opened from this command line"],"tags":["rust","helix","cli","args","layout"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}