summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/exec.zig b/src/exec.zig
index 8a24969d..722ad3de 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -980,9 +980,21 @@ pub fn executeBuiltinLine(p: *Pardes, id: usize, txt: []const u8) bool {
}
pub fn applyStartupConfig(p: *Pardes) void {
+ applyInitText(p, p.opts.startup_config orelse return, false);
+}
+
+/// The init file saved in a pane: its settings applied again. Only its
+/// setting lines: a command in it (`Newcol`) is the session's start, and
+/// would not be right twice.
+pub fn reapplyInitFile(p: *Pardes, path: []const u8, text: []const u8) void {
+ const init_path = p.opts.startup_config_path orelse return;
+ if (!std.mem.eql(u8, init_path, path)) return;
+ applyInitText(p, text, true);
+}
+
+fn applyInitText(p: *Pardes, text: []const u8, settings_only: bool) void {
p.announce = false;
defer p.announce = true;
- const text = p.opts.startup_config orelse return;
// A UTF-8 BOM an editor left at its start is no part of its first word.
const body = if (std.mem.startsWith(u8, text, "\xEF\xBB\xBF")) text[3..] else text;
var lines = std.mem.splitScalar(u8, body, '\n');
@@ -993,6 +1005,7 @@ pub fn applyStartupConfig(p: *Pardes) void {
// `#` starts a comment only at a line's start: a value may hold one
// (`#ff0000`).
if (word.len == 0 or isComment(word)) continue;
+ if (settings_only and config.Runtime.find(word[0 .. std.mem.indexOfAny(u8, word, " \t") orelse word.len]) == null) continue;
const failures = p.fs.failures;
const known = executeBuiltinLine(p, p.active, line);
if (known and p.fs.failures == failures) continue;