fix: previewing and editing files on windows (#214)
This commit is contained in:
parent
6175bd6462
commit
3727410e48
1 changed files with 16 additions and 18 deletions
|
|
@ -565,39 +565,37 @@ M.select = function(opts, callback)
|
||||||
keepalt = true,
|
keepalt = true,
|
||||||
emsg_silent = true,
|
emsg_silent = true,
|
||||||
}
|
}
|
||||||
-- If we're editing a file on disk, shorten the path prior to :edit so the
|
local filebufnr = vim.fn.bufadd(normalized_url)
|
||||||
-- display name will show up shortened
|
|
||||||
if adapter.name == "files" and not util.parse_url(normalized_url) then
|
|
||||||
normalized_url = require("oil.fs").shorten_path(normalized_url)
|
|
||||||
end
|
|
||||||
local filename = util.escape_filename(normalized_url)
|
|
||||||
|
|
||||||
-- If we're previewing a file that hasn't been opened yet, make sure it gets deleted after we
|
if opts.preview then
|
||||||
-- close the window
|
-- If we're previewing a file that hasn't been opened yet, make sure it gets deleted after
|
||||||
if opts.preview and not util.parse_url(filename) then
|
-- we close the window
|
||||||
local bufnr = vim.fn.bufadd(filename)
|
if not vim.endswith(normalized_url, "/") and vim.fn.bufloaded(filebufnr) == 0 then
|
||||||
if vim.fn.bufloaded(bufnr) == 0 then
|
vim.bo[filebufnr].bufhidden = "wipe"
|
||||||
vim.bo[bufnr].bufhidden = "wipe"
|
vim.b[filebufnr].oil_preview_buffer = true
|
||||||
vim.b[bufnr].oil_preview_buffer = true
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
-- The :buffer command doesn't set buflisted=true
|
||||||
|
vim.bo[filebufnr].buflisted = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd
|
local cmd
|
||||||
if opts.preview and preview_win then
|
if opts.preview and preview_win then
|
||||||
vim.api.nvim_set_current_win(preview_win)
|
vim.api.nvim_set_current_win(preview_win)
|
||||||
cmd = "edit"
|
cmd = "buffer"
|
||||||
else
|
else
|
||||||
if opts.tab then
|
if opts.tab then
|
||||||
cmd = "tabedit"
|
vim.cmd.tabnew({ mods = mods })
|
||||||
|
cmd = "buffer"
|
||||||
elseif opts.split then
|
elseif opts.split then
|
||||||
cmd = "split"
|
cmd = "sbuffer"
|
||||||
else
|
else
|
||||||
cmd = "edit"
|
cmd = "buffer"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vim.cmd({
|
vim.cmd({
|
||||||
cmd = cmd,
|
cmd = cmd,
|
||||||
args = { filename },
|
args = { filebufnr },
|
||||||
mods = mods,
|
mods = mods,
|
||||||
})
|
})
|
||||||
if opts.preview then
|
if opts.preview then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue