mksession: named acwrite buffer saved as enew + :file instead of :edit (E95 with 'hidden', content not restored)

Đang mở
#21,746 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 13 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, vim
Lĩnh vực
tooling

Hướng nghiên cứu

Start by reproducing with the two shell commands in the report, using --clean and a small acw.vim that sets a BufReadCmd for foo://*. Then find where :mksession writes the buffer restore step and why it emits enew plus :file for buftype=acwrite buffers instead of :edit. Done means the saved session sources without E95 under 'hidden' and the restored buffer re-reads its content through BufReadCmd.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Steps to reproduce

A named buftype=acwrite buffer (as used by plugins with BufReadCmd/BufWriteCmd, e.g. foo://bar) is written by :mksession as

badd +0 foo://bar
...
enew
file foo://bar

instead of edit foo://bar.

With 'hidden' set, sourcing the session while that buffer is still open fails with E95, because the original buffer stays loaded when enew runs:

" acw.vim
autocmd BufReadCmd foo://* call setline(1, 'content')
vim --clean -c 'set hidden' -c 'source acw.vim' -c 'e foo://bar' -c 'setlocal buftype=acwrite' -c 'mksession! s.vim' -c 'qa!'
vim --clean -c 'set hidden' -c 'source acw.vim' -c 'e foo://bar' -c 'setlocal buftype=acwrite' -c 'source s.vim'

Result:

E95: Buffer with this name already exists

:ls! then shows the original foo://bar buffer hidden and the current buffer as [No Name].

With 'nohidden' the original buffer is unloaded by enew, so :file takes over its name without E95. But the restored buffer is empty ("foo://bar" [Not edited] --No lines in buffer--), because enew + :file never triggers BufReadCmd.

This shows up in Neovim ('hidden' is on by default there), e.g. with :restart and plugins like oil.nvim (oil://). Originally reported at https://github.com/neovim/neovim/issues/42387.

Expected behaviour

The session restores the buffer with :edit foo://bar, which re-reads it via BufReadCmd and does not conflict with an already open buffer of the same name.

Version of Vim

9.1.1752 (macOS arm64)

Environment

macOS (Darwin 27.2.0), tmux, TERM=xterm-256color

Logs and stack traces

No response

Ngôn ngữ chính
Vim Script
Star
41.4k
Fork
6.2k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vim/vim

Tất cả issue của vim/vim

Issue tương tự

Thêm issue về DevTools

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.