Skip to content

Commit 1ee4ae0

Browse files
committed
fix(files): stop re-opening floating window when opening file from fuzzy search, also force stopinsert on <esc> to fix #189
1 parent 2152f18 commit 1ee4ae0

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

lua/neo-tree/sources/filesystem/init.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ local follow_internal = function(callback, force_show)
3838
end
3939

4040
local state = get_state()
41+
if state.current_position == "float" then
42+
return false
43+
end
4144
if not state.path then
4245
return false
4346
end
@@ -183,7 +186,6 @@ M.reset_search = function(state, refresh, open_current_node)
183186
end
184187
state.search_pattern = nil
185188
state.open_folders_before_search = nil
186-
if refresh then
187189
if open_current_node then
188190
local success, node = pcall(state.tree.get_node, state.tree)
189191
if success and node then
@@ -195,15 +197,13 @@ M.reset_search = function(state, refresh, open_current_node)
195197
pcall(renderer.focus_node, state, path, false)
196198
end)
197199
else
198-
if state.current_position == "current" then
199-
utils.open_file(state, node:get_id())
200-
else
201-
utils.open_file(state, path)
200+
utils.open_file(state, path)
201+
if refresh and state.current_position ~= "current" and state.current_position ~= "float" then
202202
M.navigate(state, nil, path)
203203
end
204204
end
205205
end
206-
else
206+
else if refresh then
207207
M.navigate(state)
208208
end
209209
end

lua/neo-tree/sources/filesystem/lib/filter.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ M.show_filter = function(state, search_as_you_type, fuzzy_finder_mode)
6262
fs.reset_search(state)
6363
else
6464
if search_as_you_type and fuzzy_finder_mode then
65-
state.search_pattern = nil
6665
fs.reset_search(state, true, true)
67-
require("neo-tree.sources.filesystem.commands").open(state)
6866
return
6967
end
7068
state.search_pattern = value
@@ -149,6 +147,7 @@ M.show_filter = function(state, search_as_you_type, fuzzy_finder_mode)
149147
end
150148
end)
151149
input:map("i", "<esc>", function(bufnr)
150+
vim.cmd("stopinsert")
152151
input:unmount()
153152
if fuzzy_finder_mode and utils.truthy(state.search_pattern) then
154153
fs.reset_search(state, true)
@@ -157,6 +156,7 @@ M.show_filter = function(state, search_as_you_type, fuzzy_finder_mode)
157156
end, { noremap = true })
158157

159158
input:on({ event.BufLeave, event.BufDelete }, function()
159+
vim.cmd("stopinsert")
160160
input:unmount()
161161
-- If this was closed due to submit, that function will handle the reset_search
162162
vim.defer_fn(function ()

lua/neo-tree/ui/inputs.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
local vim = vim
22
local Input = require("nui.input")
3-
local NuiText = require("nui.text")
4-
local highlights = require("neo-tree.ui.highlights")
53
local popups = require("neo-tree.ui.popups")
64
local utils = require("neo-tree.utils")
75

@@ -15,7 +13,8 @@ end
1513
M.show_input = function(input, callback)
1614
input:mount()
1715

18-
input:map("i", "<esc>", function(bufnr)
16+
input:map("i", "<esc>", function()
17+
vim.cmd("stopinsert")
1918
input:unmount()
2019
end, { noremap = true })
2120

0 commit comments

Comments
 (0)