From 17d71eb3d88a79dbc87c6245f8490853a5c38092 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Tue, 12 Mar 2024 20:05:57 -0700 Subject: [PATCH] fix: window options sometimes not set in oil buffer (#287) --- lua/oil/init.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 7dc332e..d507601 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -1082,17 +1082,16 @@ M.setup = function(opts) local bufname = vim.api.nvim_buf_get_name(0) local scheme = util.parse_url(bufname) if scheme and config.adapters[scheme] then - require("oil.view").maybe_set_cursor() + local view = require("oil.view") + view.maybe_set_cursor() -- While we are in an oil buffer, set the alternate file to the buffer we were in prior to -- opening oil local has_orig, orig_buffer = pcall(vim.api.nvim_win_get_var, 0, "oil_original_buffer") if has_orig and vim.api.nvim_buf_is_valid(orig_buffer) then vim.fn.setreg("#", orig_buffer) end - if not vim.w.oil_did_enter then - require("oil.view").set_win_options() - vim.w.oil_did_enter = true - end + view.set_win_options() + vim.w.oil_did_enter = true elseif vim.fn.isdirectory(bufname) == 0 then -- Only run this logic if we are *not* in an oil buffer (and it's not a directory, which -- will be replaced by an oil:// url)