From f193280e9a666297d631dda0be358008a4b26fe2 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 27 Oct 2026 13:55:29 +0000 Subject: [PATCH] update --- LOG.md | 1 + MIGRATION_PLAN.md | 1 + lua/netrw-config.lua | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/LOG.md b/LOG.md index 80368f7..a22e7e1 100644 --- a/LOG.md +++ b/LOG.md @@ -185,6 +185,7 @@ Record every decision here with a short rationale. Append new entries; do not re - 2026-10-27: Live validation confirmed Intelephense attaches in `WORKSPACE_TEST` and receives the trusted external `includePaths`. Conform reports prettier, phpcbf, and stylua available; nvim-lint resolves eslint_d, phpcs, and markdownlint. - 2026-10-27: Updated `AGENTS.md` status and LSP architecture notes to reflect completed colorscheme work and the current Phase 12 implementation. - 2026-10-27: Added Conform's built-in `ruff_format` for Python. Ruff was already Mason-managed for diagnostics; this closes a gap where documentation claimed Python formatting but format-on-save had no Python formatter and disabled LSP fallback. +- 2026-10-27: Fixed `` in netrw when no previous real-file buffer has been recorded. Buffer classification now rejects `nil`, non-numeric, and non-positive buffer identifiers before calling Neovim's buffer API, allowing the mapping to fall back safely. ## Project-Local Configuration diff --git a/MIGRATION_PLAN.md b/MIGRATION_PLAN.md index 75f77d2..8cadd4b 100644 --- a/MIGRATION_PLAN.md +++ b/MIGRATION_PLAN.md @@ -484,6 +484,7 @@ Source of truth for the step-by-step rebuild. Keep this concise and up to date. - [ ] Validate Oil.nvim file operations - [x] Fix working directory behavior (disabled autochdir, locked Telescope to project root) - [x] Make alternate-buffer jumps skip netrw explorer buffers when returning to the last real file +- [x] Guard alternate-buffer tracking against unset or invalid buffer numbers ## Phase 12.5 — Language tooling validation - [ ] Validate HTML/PHP/JS/Markdown tooling diff --git a/lua/netrw-config.lua b/lua/netrw-config.lua index 94b9fcd..0790a02 100644 --- a/lua/netrw-config.lua +++ b/lua/netrw-config.lua @@ -2,8 +2,12 @@ local map = vim.keymap.set local last_file_buf local previous_file_buf +local function is_valid_buffer(buf) + return type(buf) == 'number' and buf > 0 and vim.api.nvim_buf_is_valid(buf) +end + local function is_real_file_buffer(buf) - return vim.api.nvim_buf_is_valid(buf) + return is_valid_buffer(buf) and vim.bo[buf].buflisted and vim.bo[buf].buftype == '' and vim.bo[buf].filetype ~= 'netrw' @@ -11,7 +15,7 @@ local function is_real_file_buffer(buf) end local function is_netrw_buffer(buf) - if not vim.api.nvim_buf_is_valid(buf) then + if not is_valid_buffer(buf) then return false end