diff options
author | JJ | 2023-11-01 02:56:41 +0000 |
---|---|---|
committer | JJ | 2023-11-01 04:08:59 +0000 |
commit | f441f0571f7d8e140384fe75621fa69cec3265c0 (patch) | |
tree | 09aa7e83ee2972868754d3a8d25945a5f7713a4d /helix-view/src | |
parent | 696fa18edece20f10d8b276728c55ad712be1da9 (diff) |
Make initial editing mode configurable
ref: https://github.com/helix-editor/helix/pull/3366
Co-authored-by: Philipp Emanuel Weidmann <pew@worldwidemann.com>
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/editor.rs | 7 |
1 files changed, 6 insertions, 1 deletions
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 = |