Debug mode

Features:
- Display debug menu on configuration error
- Configure wether xplr should show the debug menu
    (through `debug_on_error`)
- Open logs in editor
- Redirect people to the issues page on Github.
pull/429/head
Tom van Dijk 2 years ago
parent ebbce317a0
commit 17f3893198
No known key found for this signature in database
GPG Key ID: 7A984C8207ADBA51

@ -38,6 +38,14 @@ of [modes][4] and the key mappings for each mode.
| ~ | | go home |
| [0-9] | | input |
### debug
| key | remaps | action |
| -------| ------ | --------------------|
| ctrl-c | | terminate |
| enter | | open logs in editor |
| esc | | escape |
### recover
| key | remaps | action |

@ -3,6 +3,12 @@
This configuration is exposed via the `xplr.config.general` API. It contains
the following fields:
## debug_on_error
Type: boolean
Set it to `true` to debug errors if they occur during startup.
## enable_mouse
Type: boolean

@ -20,6 +20,7 @@ This is exposed by the `xplr.config.modes.builtin` API.
xplr by default provides the following builtin modes:
- default
- debug
- recover
- selection_ops
- create

@ -1424,10 +1424,15 @@ impl App {
last_modes: Default::default(),
};
let has_errs = !load_errs.is_empty();
for err in load_errs {
app = app.log_error(err)?
}
if has_errs && app.config.general.debug_on_error {
app = app.switch_mode_builtin("debug")?;
}
Ok(app)
}
@ -2672,6 +2677,7 @@ impl App {
[
&builtin.default,
&builtin.debug,
&builtin.recover,
&builtin.filter,
&builtin.number,

@ -215,6 +215,9 @@ pub struct PanelUi {
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GeneralConfig {
#[serde(default)]
pub debug_on_error: bool,
#[serde(default)]
pub enable_mouse: bool,
@ -520,6 +523,9 @@ pub struct BuiltinModesConfig {
#[serde(default)]
pub default: Mode,
#[serde(default)]
pub debug: Mode,
#[serde(default)]
pub recover: Mode,
@ -576,6 +582,7 @@ impl BuiltinModesConfig {
pub fn get(&self, name: &str) -> Option<&Mode> {
match name {
"default" => Some(&self.default),
"debug" => Some(&self.debug),
"recover" => Some(&self.recover),
"selection ops" => Some(&self.selection_ops),
"selection_ops" => Some(&self.selection_ops),

@ -7,6 +7,9 @@ local xplr = xplr
-- Config
---- General
------ Debug on error
xplr.config.general.debug_on_error = true
------ Show hidden
xplr.config.general.show_hidden = false
@ -973,6 +976,70 @@ xplr.config.modes.builtin.default.key_bindings.on_key["k"] =
xplr.config.modes.builtin.default.key_bindings.on_key["l"] =
xplr.config.modes.builtin.default.key_bindings.on_key.right
xplr.config.modes.builtin.debug = {
name = "debug",
help = nil,
extra_help = nil,
layout = {
Vertical = {
config = {
constraints = {
{ Min = 9 },
{ MinLessThanScreenHeight = 9 },
}
},
splits = {
{
CustomContent = {
title = "debug mode",
body = {
StaticParagraph = {
render = [[Startup errors have occured. Check your init.lua for errors.
If you think this is a bug, report your error at:
https://github.com/sayanarijit/xplr/issues/new
To open the logs in your editor, press `enter`.
To ignore the errors continue in the default config, press `escape`.]]
}
},
},
},
"InputAndLogs",
}
}
},
key_bindings = {
on_key = {
["ctrl-c"] = {
help = "terminate",
messages = {"Terminate"}
},
enter = {
help = "open logs in editor",
messages = {
{
BashExec = [===[
${EDITOR:-vi} "${XPLR_PIPE_LOGS_OUT:?}"
]===],
},
},
},
esc = {
help = "escape",
messages = {"PopMode"}
}
},
on_alphabet = nil,
on_number = nil,
on_special_character = nil,
default = {
help = nil,
messages = {}
}
}
}
------ Recover
xplr.config.modes.builtin.recover = {
name = "recover",

Loading…
Cancel
Save