{"record":{"id":"129cdd113728da70","repo":"helix-editor/helix","slug":"line-number-can-only-be-absolute-or-relative","errorCode":null,"errorMessage":"Line number can only be `absolute` or `relative`.","messagePattern":"Line number can only be `absolute` or `relative`\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"helix-view/src/editor.rs","lineNumber":894,"sourceCode":"#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]\n#[serde(rename_all = \"kebab-case\")]\npub enum LineNumber {\n    /// Show absolute line number\n    Absolute,\n\n    /// If focused and in normal/select mode, show relative line number to the primary cursor.\n    /// If unfocused or in insert mode, show absolute line number.\n    Relative,\n}\n\nimpl std::str::FromStr for LineNumber {\n    type Err = anyhow::Error;\n\n    fn from_str(s: &str) -> Result<Self, Self::Err> {\n        match s.to_lowercase().as_str() {\n            \"absolute\" | \"abs\" => Ok(Self::Absolute),\n            \"relative\" | \"rel\" => Ok(Self::Relative),\n            _ => anyhow::bail!(\"Line number can only be `absolute` or `relative`.\"),\n        }\n    }\n}\n\n#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]\n#[serde(rename_all = \"kebab-case\")]\npub enum GutterType {\n    /// Show diagnostics and other features like breakpoints\n    Diagnostics,\n    /// Show line numbers\n    LineNumbers,\n    /// Show one blank space\n    Spacer,\n    /// Highlight local changes\n    Diff,\n    /// Indicator for when code actions are available\n    CodeActionHint,\n}","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-view/src/editor.rs#L876-L912","documentation":"LineNumber is the config enum behind Helix's line-number setting; its FromStr impl accepts only \"absolute\"/\"abs\" and \"relative\"/\"rel\" (case-insensitive). Any other string fails with this error when config.toml is parsed, because serde deserializes line-number through FromStr. The aliases exist precisely so short forms work, but nothing else does.","triggerScenarios":"Setting line-number = \"smart\", \"hybrid\", or a typo like \"relatve\" in config.toml; deserializing a LineNumber from any non-enum string via code that uses .parse().","commonSituations":"Users migrating from other editors request \"relative to cursor only in normal mode\" styles (e.g. Vim's number+relativenumber hybrid) and guess a keyword; JSON/TOML typos; copying config snippets written for a different editor version that used different values.","solutions":["Set line-number = \"relative\" or \"absolute\" in config.toml (\"rel\"/\"abs\" also accepted).","There is no hybrid mode on this key; relative-in-normal/absolute-in-insert behavior is a separate setting (relative-line-numbers style behavior is not configured through this value), so remove the invalid keyword.","After editing, run :config-reload and confirm no error appears; check :log-open for the offending key path."],"exampleFix":"# before (config.toml)\n line-number = \"hybrid\" # parse error\n\n# after\n line-number = \"relative\"","handlingStrategy":"validation","validationCode":"fn is_valid_line_number(s: &str) -> bool {\n    matches!(s.to_lowercase().as_str(), \"absolute\" | \"abs\" | \"relative\" | \"rel\")\n}","typeGuard":"fn parse_line_number(s: &str) -> Option<LineNumber> {\n    match s.to_lowercase().as_str() {\n        \"absolute\" | \"abs\" => Some(LineNumber::Absolute),\n        \"relative\" | \"rel\" => Some(LineNumber::Relative),\n        _ => None,\n    }\n}","tryCatchPattern":"match value.parse::<LineNumber>() {\n    Ok(v) => editor.line_number = v,\n    Err(_) => {\n        eprintln!(\"config: line-number must be 'absolute' or 'relative', got '{value}'\");\n        editor.line_number = LineNumber::Absolute; // safe default\n    }\n}","preventionTips":["Validate config values against the enum before parsing.","Keep a single source of truth for accepted strings (test config against the parser in CI).","Lint user config.toml on startup and report the offending key path."],"tags":["config","line-numbers","helix","rust"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}