1007 do not wipe modified buffers when hijack unnamed buffer when opening (#1009)

This commit is contained in:
Alexander Courtis 2022-02-20 20:41:47 +11:00 committed by GitHub
parent 589e39d642
commit a1937ca079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View File

@ -127,7 +127,7 @@ require'nvim-tree'.setup {
open_on_tab = false, open_on_tab = false,
hijack_cursor = false, hijack_cursor = false,
update_cwd = false, update_cwd = false,
hijack_unnamed_buffer_when_opening = true, hijack_unnamed_buffer_when_opening = false,
hijack_directories = { hijack_directories = {
enable = true, enable = true,
auto_open = true, auto_open = true,

View File

@ -84,7 +84,7 @@ function.
open_on_tab = false, open_on_tab = false,
hijack_cursor = false, hijack_cursor = false,
update_cwd = false, update_cwd = false,
hijack_unnamed_buffer_when_opening = true, hijack_unnamed_buffer_when_opening = false,
diagnostics = { diagnostics = {
enable = false, enable = false,
show_on_dirs = false, show_on_dirs = false,
@ -188,7 +188,7 @@ Here is a list of the options available in the setup call:
- |hijack_unnamed_buffer_when_opening|: opens in place of the unnamed - |hijack_unnamed_buffer_when_opening|: opens in place of the unnamed
buffer if it's empty. buffer if it's empty.
type: `boolean` type: `boolean`
default: `true` default: `false`
*nvim-tree.hijack_directories* *nvim-tree.hijack_directories*
- |hijack_directories|: hijacks new directory buffers when they are opened (`:e dir`). - |hijack_directories|: hijacks new directory buffers when they are opened (`:e dir`).

View File

@ -290,7 +290,7 @@ local DEFAULT_OPTS = {
hijack_cursor = false, hijack_cursor = false,
update_cwd = false, update_cwd = false,
hide_root_folder = false, hide_root_folder = false,
hijack_unnamed_buffer_when_opening = true, hijack_unnamed_buffer_when_opening = false,
update_focused_file = { update_focused_file = {
enable = false, enable = false,
update_cwd = false, update_cwd = false,

View File

@ -129,6 +129,7 @@ function M.open(cwd)
local bufnr = api.nvim_get_current_buf() local bufnr = api.nvim_get_current_buf()
if M.hijack_unnamed_buffer_when_opening if M.hijack_unnamed_buffer_when_opening
and api.nvim_buf_get_name(bufnr) == "" and api.nvim_buf_get_name(bufnr) == ""
and not api.nvim_buf_get_option(bufnr, "modified")
and api.nvim_buf_get_option(bufnr, "ft") == "" then and api.nvim_buf_get_option(bufnr, "ft") == "" then
view.open_in_current_win() view.open_in_current_win()
renderer.draw() renderer.draw()