From f441f0571f7d8e140384fe75621fa69cec3265c0 Mon Sep 17 00:00:00 2001 From: JJ Date: Tue, 31 Oct 2023 19:56:41 -0700 Subject: Make initial editing mode configurable ref: https://github.com/helix-editor/helix/pull/3366 Co-authored-by: Philipp Emanuel Weidmann --- helix-view/src/editor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'helix-view/src') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index b2615c9f..a9014fe7 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -306,6 +306,8 @@ pub struct Config { pub indent_guides: IndentGuidesConfig, /// Explorer configuration. pub explorer: ExplorerConfig, + /// The initial mode for newly opened editors. Defaults to `"normal"`. + pub initial_mode: Mode, /// Whether to color modes with different colors. Defaults to `false`. pub color_modes: bool, /// Whether to render rainbow highlights. Defaults to `false`. @@ -874,6 +876,7 @@ impl Default for Config { bufferline: BufferLine::default(), indent_guides: IndentGuidesConfig::default(), explorer: ExplorerConfig::default(), + initial_mode: Mode::Normal, color_modes: false, rainbow_brackets: false, soft_wrap: SoftWrap { @@ -1359,7 +1362,8 @@ impl Editor { return; } - self.enter_normal_mode(); + // this causes tree.rs to panic upon launch. todo: debug + // self.enter_normal_mode(); match action { Action::Replace => { @@ -1448,6 +1452,7 @@ impl Editor { /// Generate an id for a new document and register it. fn new_document(&mut self, mut doc: Document) -> DocumentId { + self.mode = self.config().initial_mode; let id = self.next_document_id; // Safety: adding 1 from 1 is fine, probably impossible to reach usize max self.next_document_id = -- cgit v1.2.3-70-g09d2