diff --git a/build.zig b/build.zig index 7f1d998..444221e 100644 --- a/build.zig +++ b/build.zig @@ -440,6 +440,7 @@ pub fn build_exe( .{ .name = "thespian", .module = thespian_mod }, .{ .name = "cbor", .module = cbor_mod }, .{ .name = "log", .module = log_mod }, + .{ .name = "bin_path", .module = bin_path_mod }, }, }); diff --git a/contrib/test_race.sh b/contrib/test_race.sh new file mode 100755 index 0000000..a2a4b09 --- /dev/null +++ b/contrib/test_race.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +if [ "$1" == "--build" ]; then + shift + echo "building..." + zig build -freference-trace --prominent-compile-errors +fi + +for i in {1..60}; do + echo "running $i ..." + flow --exec quit "$@" || exit 1 +done diff --git a/src/keybind/builtin/flow.json b/src/keybind/builtin/flow.json index 29dae9e..4de41a2 100644 --- a/src/keybind/builtin/flow.json +++ b/src/keybind/builtin/flow.json @@ -157,6 +157,7 @@ ["f9", "theme_prev"], ["f10", "theme_next"], ["f11", "toggle_panel"], + ["shift+f11", "toggle_highlight_columns"], ["ctrl+f11", "toggle_inspector_view"], ["f12", "goto_definition"], ["f34", "toggle_whitespace_mode"], diff --git a/src/renderer/vaxis/renderer.zig b/src/renderer/vaxis/renderer.zig index 1b11617..11b99dd 100644 --- a/src/renderer/vaxis/renderer.zig +++ b/src/renderer/vaxis/renderer.zig @@ -95,13 +95,16 @@ pub fn deinit(self: *Self) void { self.event_buffer.deinit(); } +var in_panic: std.atomic.Value(bool) = .init(false); var panic_cleanup: ?struct { allocator: std.mem.Allocator, tty: *vaxis.Tty, vx: *vaxis.Vaxis, } = null; + pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn { _ = error_return_trace; // TODO: what to do with this in zig-0.14? + in_panic.store(true, .release); const cleanup = panic_cleanup; panic_cleanup = null; if (cleanup) |self| { @@ -111,6 +114,10 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_ return std.debug.defaultPanic(msg, ret_addr orelse @returnAddress()); } +pub fn panic_in_progress() bool { + return in_panic.load(.acquire); +} + pub fn run(self: *Self) Error!void { self.vx.sgr = .legacy; self.vx.conpty_hacks = true; @@ -130,6 +137,7 @@ pub fn run(self: *Self) Error!void { } pub fn render(self: *Self) !void { + if (in_panic.load(.acquire)) return; var bufferedWriter = self.tty.bufferedWriter(); try self.vx.render(bufferedWriter.writer().any()); try bufferedWriter.flush(); diff --git a/src/ripgrep.zig b/src/ripgrep.zig index c99b625..102fcaa 100644 --- a/src/ripgrep.zig +++ b/src/ripgrep.zig @@ -126,6 +126,7 @@ const Process = struct { "--json", "--smart-case", self.query, + "./.", // never search stdin }); self.sp = tp.subprocess.init(self.allocator, args, module_name, self.stdin_behavior) catch |e| return tp.exit_error(e, @errorReturnTrace()); tp.receive(&self.receiver); diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 083e715..607c037 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -24,6 +24,7 @@ allocator: Allocator, rdr_: renderer, config_: @import("config"), highlight_columns_: []u16, +highlight_columns_configured: []u16, frame_time: usize, // in microseconds frame_clock: tp.metronome, frame_clock_running: bool = false, @@ -130,12 +131,14 @@ fn init(allocator: Allocator) InitError!*Self { idx += 1; break :blk idx; }; + const highlight_columns__ = try allocator.alloc(u16, hl_cols); var self = try allocator.create(Self); self.* = .{ .allocator = allocator, .config_ = conf, - .highlight_columns_ = try allocator.alloc(u16, hl_cols), + .highlight_columns_ = highlight_columns__, + .highlight_columns_configured = highlight_columns__, .rdr_ = try renderer.init(allocator, self, tp.env.get().is("no-alternate"), dispatch_initialized), .frame_time = frame_time, .frame_clock = frame_clock, @@ -221,6 +224,7 @@ fn init_delayed(self: *Self) command.Result { } fn deinit(self: *Self) void { + self.allocator.free(self.highlight_columns_configured); if (self.mouse_idle_timer) |*t| { t.cancel() catch {}; t.deinit(); @@ -788,6 +792,12 @@ const cmds = struct { } pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Next whitespace mode" }; + pub fn toggle_highlight_columns(self: *Self, _: Ctx) Result { + defer self.logger.print("highlight columns {s}", .{if (self.highlight_columns_.len > 0) "enabled" else "disabled"}); + self.highlight_columns_ = if (self.highlight_columns_.len > 0) &.{} else self.highlight_columns_configured; + } + pub const toggle_highlight_columns_meta: Meta = .{ .description = "Toggle highlight columns" }; + pub fn toggle_input_mode(self: *Self, _: Ctx) Result { var it = std.mem.splitScalar(u8, self.config_.input_mode, '/'); self.config_.input_mode = it.first();