From 195e963290dbad6fa058dfd6caf4f5a9b6591f7a Mon Sep 17 00:00:00 2001 From: TornaxO7 Date: Thu, 14 Dec 2023 18:45:30 +0100 Subject: [PATCH 1/3] removing unreachable statement in `:indent-style` --- helix-term/src/commands/typed.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 4148257fc494..cf0197d5f0f6 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -476,8 +476,7 @@ fn set_indent_style( cx.editor.set_status(match style { Tabs => "tabs".to_owned(), Spaces(1) => "1 space".to_owned(), - Spaces(n) if (2..=8).contains(&n) => format!("{} spaces", n), - _ => unreachable!(), // Shouldn't happen. + Spaces(n) => format!("{} spaces", n), }); return Ok(()); } From 12306d75e0f2fe38485512931d4eac2d88c743b1 Mon Sep 17 00:00:00 2001 From: TornaxO7 Date: Fri, 15 Dec 2023 13:35:02 +0100 Subject: [PATCH 2/3] update checks when setting indent line and update docs --- helix-core/src/indent.rs | 2 +- helix-term/src/commands/typed.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index abf45d6faf36..50f3b8c74b33 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -21,7 +21,7 @@ pub enum IndentStyle { // 16 spaces const INDENTS: &str = " "; -const MAX_INDENT: u8 = 16; +pub const MAX_INDENT: u8 = 16; impl IndentStyle { /// Creates an `IndentStyle` from an indentation string. diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index cf0197d5f0f6..1d4d65050973 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -6,6 +6,7 @@ use crate::job::Job; use super::*; use helix_core::fuzzy::fuzzy_match; +use helix_core::indent::MAX_INDENT; use helix_core::{encoding, line_ending, path::get_canonicalized_path, shellwords::Shellwords}; use helix_lsp::{OffsetEncoding, Url}; use helix_view::document::DEFAULT_LANGUAGE_NAME; @@ -488,7 +489,7 @@ fn set_indent_style( Some(arg) => arg .parse::() .ok() - .filter(|n| (1..=8).contains(n)) + .filter(|n| (1..=MAX_INDENT).contains(n)) .map(Spaces), _ => None, }; @@ -2605,7 +2606,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "indent-style", aliases: &[], - doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)", + doc: "Set the indentation style for editing. ('t' for tabs or 1-16 for number of spaces.)", fun: set_indent_style, signature: CommandSignature::none(), }, From 7db081ca003cc4e1f9637be49dee659fa417baf3 Mon Sep 17 00:00:00 2001 From: TornaxO7 Date: Fri, 15 Dec 2023 13:43:44 +0100 Subject: [PATCH 3/3] `cargo xtask docgen` --- book/src/generated/typable-cmd.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index 6280d3c72fde..f4fcb6f6200e 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -17,7 +17,7 @@ | `:write-buffer-close!`, `:wbc!` | Force write changes to disk creating necessary subdirectories and closes the buffer. Accepts an optional path (:write-buffer-close! some/path.txt) | | `:new`, `:n` | Create a new scratch buffer. | | `:format`, `:fmt` | Format the file using the LSP formatter. | -| `:indent-style` | Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.) | +| `:indent-style` | Set the indentation style for editing. ('t' for tabs or 1-16 for number of spaces.) | | `:line-ending` | Set the document's default line ending. Options: crlf, lf. | | `:earlier`, `:ear` | Jump back to an earlier point in edit history. Accepts a number of steps or a time span. | | `:later`, `:lat` | Jump to a later point in edit history. Accepts a number of steps or a time span. |