From bbad9a76b2617ce1221d49619e4e4b659b3c61fc Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Wed, 2 Jul 2025 09:18:23 -0700 Subject: [PATCH] fix: scratch preview method (#628) --- lua/oil/util.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/oil/util.lua b/lua/oil/util.lua index 3e70beb..d000071 100644 --- a/lua/oil/util.lua +++ b/lua/oil/util.lua @@ -965,8 +965,12 @@ M.read_file_to_scratch_buffer = function(path, preview_method) vim.bo[bufnr].bufhidden = "wipe" vim.bo[bufnr].buftype = "nofile" - local max_lines = preview_method == "fast_scratch" and vim.o.lines or nil - local has_lines, read_res = pcall(vim.fn.readfile, path, "", max_lines) + local has_lines, read_res + if preview_method == "fast_scratch" then + has_lines, read_res = pcall(vim.fn.readfile, path, "", vim.o.lines) + else + has_lines, read_res = pcall(vim.fn.readfile, path) + end local lines = has_lines and vim.split(table.concat(read_res, "\n"), "\n") or {} local ok = pcall(vim.api.nvim_buf_set_lines, bufnr, 0, -1, false, lines)