-
-
Notifications
You must be signed in to change notification settings - Fork 623
fix(#1785): retain focused node on filter toggle #2202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6fdbd53
feat(live-filter): focus selected node after clear
Akmadan23 22ba98f
fix(#1785): retain focused node on filter toggle
Akmadan23 2a10b4e
Merge branch 'master' into live-filter
alex-courtis 55ae145
fix(#1785): apply requested changes
Akmadan23 22dc1bd
Merge branch 'master' into live-filter
alex-courtis c19bf0b
fix(live-filter): focus last focused node when cleared on prompt
Akmadan23 608d2a8
refactor: store last focused node in `view` module
Akmadan23 59628ee
refactor: store last focused node in view module
alex-courtis 28d5360
Merge branch 'master' into live-filter
alex-courtis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,52 @@ | ||
local lib = require "nvim-tree.lib" | ||
local utils = require "nvim-tree.utils" | ||
local filters = require "nvim-tree.explorer.filters" | ||
local reloaders = require "nvim-tree.actions.reloaders.reloaders" | ||
|
||
local M = {} | ||
|
||
local function reload() | ||
local node = lib.get_node_at_cursor() | ||
reloaders.reload_explorer() | ||
local visible_nodes = require("nvim-tree.core").get_explorer().nodes | ||
Akmadan23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
while node do | ||
local found_node, _ = utils.find_node(visible_nodes, function(node_) | ||
return node_.absolute_path == node.absolute_path | ||
end) | ||
|
||
if found_node or node.parent == nil then | ||
utils.focus_file(node.absolute_path) | ||
break | ||
end | ||
|
||
node = node.parent | ||
end | ||
end | ||
|
||
function M.custom() | ||
filters.config.filter_custom = not filters.config.filter_custom | ||
return reloaders.reload_explorer() | ||
reload() | ||
end | ||
|
||
function M.git_ignored() | ||
filters.config.filter_git_ignored = not filters.config.filter_git_ignored | ||
return reloaders.reload_explorer() | ||
reload() | ||
end | ||
|
||
function M.git_clean() | ||
filters.config.filter_git_clean = not filters.config.filter_git_clean | ||
return reloaders.reload_explorer() | ||
reload() | ||
end | ||
|
||
function M.no_buffer() | ||
filters.config.filter_no_buffer = not filters.config.filter_no_buffer | ||
return reloaders.reload_explorer() | ||
reload() | ||
end | ||
|
||
function M.dotfiles() | ||
filters.config.filter_dotfiles = not filters.config.filter_dotfiles | ||
return reloaders.reload_explorer() | ||
reload() | ||
end | ||
|
||
return M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.