$E_FN crashes or uses the wrong file outside :ExecutorRun

未关闭 适合新手
#45 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
lua, neovim
领域
devtools

调研方向

首先阅读 run_one_off_cmd、set_task_command 和 get_relative_buffer_name,issue 报告的问题出现在这些位置:buffer 路径过时或为 nil。在 Neovim 中重现这两种情况:先运行 :ExecutorRun 之前运行 :ExecutorOneOff,然后在运行 :ExecutorRun 后从另一个 buffer 运行它。更新受影响路径的 buffer 选择,并验证 $E_FN 使用当前文件且不会崩溃。

由索引模型根据 Issue 内容生成。

描述

:ExecutorRun records the current buffer, and $E_FN uses that recorded buffer. Other ways of running or setting a command do not record it first, so $E_FN either crashes or uses the wrong file.

Steps to reproduce

Crash

  1. Start Neovim and open any file.
  2. Before running :ExecutorRun, run :ExecutorOneOff echo $E_FN.
  3. The command fails with Invalid 'buf': Expected Lua number. The error comes from nvim_buf_get_name(nil) in get_relative_buffer_name.

Wrong file

  1. Open a.js and run :ExecutorRun once.
  2. Switch to b.js.
  3. Run :ExecutorOneOff echo $E_FN. The command runs on a.js instead of b.js.

Affected paths

last_active_buf_id is set only in Executor.run(). These paths read it before it is set, or after it has gone stale:

  • :ExecutorOneOff (run_one_off_cmd).
  • Choosing a preset. set_task_command runs before Executor.run() records the buffer.
  • Choosing an entry from the history picker. This path also calls set_task_command before Executor.run().
  • require("executor").api.set_task_command and api.run_task.

Possible fix

Record the current buffer in run_one_off_cmd and set_task_command. Alternatively, read the current buffer directly when last_active_buf_id is nil.

主要语言
Lua
星标
161
派生
12
平均合并
25 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

google/executor.nvim 的其他 Issue

查看 google/executor.nvim 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。