repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix(dbg.viewer): display events newest-first, fix prepend ordering

1788758b6bc0f8364f1c1be33218b40425c0436e

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

- open(): reverse events after read_all() so array is newest-first
- on_file_change(): prepend new events at start of events array (not append)
- prepend_new_events(): base_idx=1 since new events now at array start
- prepend_new_events(): shift old event indices by #new_display_events
- AGENTS.md: note working dir is symlinked to ~/.config/nvim

Changed files (2)

neovim/AGENTS.md

Modified
1 1 # Neovim Configuration — bugabinga
3 +**Working directory** (`/home/me/Workspace/dotfiles/neovim`) **is symlinked to**
4 +`~/.config/nvim`. Tests run against the live config at `~/.config/nvim/lua/`.
3 6 ## Project Structure

neovim/lua/std/dbg/viewer.lua

Modified
98 98 local timeago = require 'std.timeago'
99 99 local map = require 'std.map'
101 +local start_watcher
102 +local on_file_change
101 104 local H = {
102 105 state = nil,
379 382 local new_highlights = {}
380 383 local new_line_events = {}
382 - local base_idx = H.state.event_count - #new_display_events + 1
385 + local base_idx = 1
383 386 for ei, event in ipairs(new_display_events) do
384 387 local d = format_event_for_display(event)
426 429 local shift = #new_lines
427 430 local shifted_line_events = {}
428 431 for line_idx, event_idx in pairs(H.state.line_events) do
429 - shifted_line_events[line_idx + shift] = event_idx
432 + shifted_line_events[line_idx + shift] = event_idx + #new_display_events
431 434 for line_idx, event_idx in pairs(new_line_events) do
432 435 shifted_line_events[line_idx] = event_idx
495 498 new_events = reversed
497 - for _, ev in ipairs(new_events) do
498 - H.state.events[#H.state.events + 1] = ev
500 + for i = #new_events, 1, -1 do
501 + table.insert(H.state.events, 1, new_events[i])
500 503 H.state.event_count = new_total
504 507 H.state.watcher = start_watcher()
507 -local function start_watcher()
510 +start_watcher = function()
508 511 local path = file.get_path()
509 512 local callback = function(err)
510 513 if err then return end
536 539 local events = file.read_all()
540 + for i = 1, math.floor(#events / 2) do
541 + events[i], events[#events - i + 1] = events[#events - i + 1], events[i]
542 + end
537 543 local buf_id = create_buf()
538 544 local win_id = open_win(buf_id)
539 545 setup_keymaps(buf_id, win_id)