aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorPhilipp Emanuel Weidmann2024-05-01 21:07:50 +0000
committerJJ2024-05-01 23:06:27 +0000
commit3ecf200b3469f63016b27141c20286a36d5dd9eb (patch)
treec3e5e76d99fc4fc42d39cecccf2b47a4592623a8 /helix-view/src/editor.rs
parent7cf650270c78238b5efd7ea4182205114f53540b (diff)
Make initial editing mode configurable
ref: https://github.com/helix-editor/helix/pull/3366 Co-authored-by: JJ <git@toki.la>
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 44dd1041..1cf3eb1c 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -351,6 +351,8 @@ pub struct Config {
pub jump_label_alphabet: Vec<char>,
/// Explorer configuration.
pub explorer: ExplorerConfig,
+ /// The initial mode for newly opened editors. Defaults to `"normal"`.
+ pub initial_mode: Mode,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
@@ -929,6 +931,7 @@ impl Default for Config {
indent_heuristic: IndentationHeuristic::default(),
jump_label_alphabet: ('a'..='z').collect(),
explorer: ExplorerConfig::default(),
+ initial_mode: Mode::Normal,
}
}
}
@@ -1504,7 +1507,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 => {
@@ -1593,6 +1597,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 =