Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/calltree_jump_changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# calltree 自动跳转改动差异

## 上一版(edc1394)
- 通过 `safe_buf_add_highlight` 与 `safe_win_set_cursor` 防止越界,但只在调用树调用窗口中寻找现有窗口。
- 当引用所在文件未在任何窗口打开时,不会主动载入或挂接该缓冲区,导致 `j/k` 循环无法找到可跳转窗口。
- 未显式触发 `BufRead`/`BufEnter` 等自动命令,因此后台加载的缓冲区缺失主题与 LSP 附着。

## 当前版本(简化后)
- 用 `prepare_buf` 同时负责后台加载后的 `filetype` 恢复与 `BufRead` 自动命令,减少分散的辅助函数。
- 通过 `ensure_window_has_buf` 与 `target_wins` 在需要时复用调用源窗口,同时触发 `BufWinEnter`/`BufEnter`/`WinEnter`,确保主题与 LSP 立即生效。
- `target_buf_for_node` 统一处理“调用”与“被调用”两种方向的目标缓冲区选择逻辑,并复用 `jump_to_reference` 在高亮和循环跳转之间共享跳转实现。
- 继续维护 `M.last_highlight_buf` 与 `M.last_jumped_reference`,但通过更少的状态字段即可在未打开文件之间顺畅地循环跳转。

## 关键区别
1. **窗口处理**:当前版本仍会在需要时把目标缓冲区挂到原始窗口,并触发窗口相关自动命令,但实现浓缩在 `target_wins`/`ensure_window_has_buf` 中,更易追踪。
2. **文件类型与主题**:`prepare_buf` 将 `BufRead`、`BufReadPost` 和 `filetype` 检测集中处理,不再分散到多个函数中,减少重复逻辑。
3. **跳转状态**:跳转与高亮共用 `jump_to_reference`,既保持 `j/k` 连续性,又避免重复的窗口遍历代码。
Loading