feat(preview): add max_file_size config to skip large file previews
Problem: previewing large files (e.g. 500 MB logs, binaries) loads them into a buffer and can freeze or OOM Neovim. `disable_preview` only receives the filename, so users cannot gate on file size. Solution: add `preview_win.max_file_size` (number, MB, default 10). In `open_preview`, check `entry.meta.stat.size` and fall back to `vim.uv.fs_stat` when the cached stat is absent. If the file exceeds the limit and a preview window is already open, render "File too large to preview" in it; if not, emit a WARN notify and return early. The cursor-moved auto-update path only fires when a window already exists, so no flag threading is needed to distinguish explicit from implicit. Based on: stevearc/oil.nvim#213
This commit is contained in:
parent
a9a06b8f3b
commit
4b32ada2d9
4 changed files with 47 additions and 3 deletions
|
|
@ -35,6 +35,8 @@ Bugs fixed in this fork that remain open upstream.
|
|||
| [#670](https://github.com/stevearc/oil.nvim/issues/670) | Multi-directory cmdline args ignored | [#11](https://github.com/barrettruth/canola.nvim/pull/11) ([`70861e5`](https://github.com/barrettruth/canola.nvim/commit/70861e5)) |
|
||||
| [#673](https://github.com/stevearc/oil.nvim/issues/673) | Symlink newlines crash | [`9110a1a`](https://github.com/barrettruth/canola.nvim/commit/9110a1a) |
|
||||
| [#710](https://github.com/stevearc/oil.nvim/issues/710) | buftype empty on BufEnter | [#10](https://github.com/barrettruth/canola.nvim/pull/10) ([`01b860e`](https://github.com/barrettruth/canola.nvim/commit/01b860e)) |
|
||||
| [#213](https://github.com/stevearc/oil.nvim/issues/213) | Max file size for preview | pending PR |
|
||||
| [#473](https://github.com/stevearc/oil.nvim/issues/473) | Show hidden when dir is all-hidden | pending PR |
|
||||
|
||||
## Open upstream PRs
|
||||
|
||||
|
|
@ -61,7 +63,7 @@ Bugs fixed in this fork that remain open upstream.
|
|||
| [#200](https://github.com/stevearc/oil.nvim/issues/200) | open | Highlights not working when opening a file (P2) |
|
||||
| [#207](https://github.com/stevearc/oil.nvim/issues/207) | open | Suppress "no longer available" message (P1) |
|
||||
| [#210](https://github.com/stevearc/oil.nvim/issues/210) | open | FTP support (P2) |
|
||||
| [#213](https://github.com/stevearc/oil.nvim/issues/213) | open | Disable preview for large files (P1) |
|
||||
| [#213](https://github.com/stevearc/oil.nvim/issues/213) | fixed | Disable preview for large files — `preview_win.max_file_size` (P1) |
|
||||
| [#226](https://github.com/stevearc/oil.nvim/issues/226) | open | K8s/Docker adapter (P2) |
|
||||
| [#232](https://github.com/stevearc/oil.nvim/issues/232) | open | Cannot close last window (P2) |
|
||||
| [#254](https://github.com/stevearc/oil.nvim/issues/254) | open | Buffer modified highlight group (P2) |
|
||||
|
|
@ -104,7 +106,7 @@ Bugs fixed in this fork that remain open upstream.
|
|||
| [#450](https://github.com/stevearc/oil.nvim/issues/450) | open | Highlight opened file in directory listing |
|
||||
| [#457](https://github.com/stevearc/oil.nvim/issues/457) | open | Custom column API |
|
||||
| [#466](https://github.com/stevearc/oil.nvim/issues/466) | open | Select into window on right |
|
||||
| [#473](https://github.com/stevearc/oil.nvim/issues/473) | open | Show all hidden files if dir only has hidden |
|
||||
| [#473](https://github.com/stevearc/oil.nvim/issues/473) | fixed | Show all hidden files if dir only has hidden — `view_options.show_hidden_when_empty` |
|
||||
| [#479](https://github.com/stevearc/oil.nvim/issues/479) | open | Harpoon integration recipe |
|
||||
| [#483](https://github.com/stevearc/oil.nvim/issues/483) | not actionable | Spell downloads depend on netrw — fixed in [neovim#34940](https://github.com/neovim/neovim/pull/34940) |
|
||||
| [#486](https://github.com/stevearc/oil.nvim/issues/486) | open | All directory sizes show 4.1k |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue