Make settings editor launch robust

This commit is contained in:
2026-07-16 23:44:17 +09:00
parent 622e6dd781
commit e5a4e91ec2

View File

@@ -155,7 +155,15 @@ local function open_config_section(window, pane, line)
args = { args = {
"sh", "sh",
"-lc", "-lc",
string.format('editor="${EDITOR:-vi}"; exec "$editor" +%d %q', line, config_file), string.format(
'file=%q; line=%d; editor="${VISUAL:-${EDITOR:-}}"; '
.. 'if [ -z "$editor" ]; then for candidate in nvim vim vi nano; do command -v "$candidate" >/dev/null 2>&1 && editor="$candidate" && break; done; fi; '
.. 'if [ -z "$editor" ]; then echo "No terminal editor found. Set EDITOR or install vim/nano."; exec "${SHELL:-sh}"; fi; '
.. '"$editor" +"$line" "$file"; status=$?; '
.. 'if [ $status -ne 0 ]; then echo; echo "Editor exited with status $status. Press Enter to close, or type commands below."; exec "${SHELL:-sh}"; fi',
config_file,
line
),
}, },
}), }),
pane pane