-
-
Notifications
You must be signed in to change notification settings - Fork 632
fix(#3327): pass nvim_tree.api.node.open.Opts to all applicable nvim_tree.api.node.open function #3329
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
+140
−66
Merged
fix(#3327): pass nvim_tree.api.node.open.Opts to all applicable nvim_tree.api.node.open function #3329
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5acd706
fix(#3327): pass nvim_tree.api.node.open.Opts to all applicable nvim_…
alex-courtis 2ef745d
fix(#3327): pass nvim_tree.api.node.open.Opts to all applicable nvim_…
alex-courtis 9310cec
fix(#3327): pass nvim_tree.api.node.open.Opts to all applicable nvim_…
alex-courtis fc69cb3
fix(#3327): pass nvim_tree.api.node.open.Opts to all applicable nvim_…
alex-courtis a256ac0
fix(#3327): pass nvim_tree.api.node.open.Opts to all applicable nvim_…
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
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
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 |
|---|---|---|
|
|
@@ -10,10 +10,6 @@ local DirectoryNode = require("nvim-tree.node.directory") | |
| local FileLinkNode = require("nvim-tree.node.file-link") | ||
| local RootNode = require("nvim-tree.node.root") | ||
|
|
||
| ---@class NodeEditOpts | ||
| ---@field quit_on_open boolean|nil default false | ||
| ---@field focus boolean|nil default true | ||
|
|
||
| ---@alias NodeOpenFileMode ""|"change_dir"|"drop"|"edit"|"edit_in_place"|"edit_no_picker"|"preview"|"preview_no_picker"|"split"|"split_no_picker"|"tab_drop"|"tabnew"|"toggle_group_empty"|"vsplit"|"vsplit_no_picker" | ||
|
|
||
| local M = {} | ||
|
|
@@ -416,7 +412,7 @@ end | |
|
|
||
| ---@param mode string | ||
| ---@param node Node | ||
| ---@param edit_opts NodeEditOpts? | ||
| ---@param edit_opts nvim_tree.api.node.open.Opts? | ||
| local function edit(mode, node, edit_opts) | ||
| local file_link = node:as(FileLinkNode) | ||
| local path = file_link and file_link.link_to or node.absolute_path | ||
|
|
@@ -432,7 +428,7 @@ local function edit(mode, node, edit_opts) | |
| end | ||
|
|
||
| local mode_unsupported_focus = mode == "drop" or mode == "tab_drop" or mode == "edit_in_place" | ||
| local focus = edit_opts.focus == nil or edit_opts.focus == true | ||
| local focus = edit_opts.focus == nil or edit_opts.focus == false | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was incorrect. Fixed to match doc. |
||
| if not mode_unsupported_focus and not focus then | ||
| -- if mode == "tabnew" a new tab will be opened and we need to focus back to the previous tab | ||
| if mode == "tabnew" then | ||
|
|
@@ -445,7 +441,7 @@ end | |
| ---@param node Node | ||
| ---@param mode NodeOpenFileMode | ||
| ---@param toggle_group boolean? | ||
| ---@param edit_opts NodeEditOpts? | ||
| ---@param edit_opts nvim_tree.api.node.open.Opts? | ||
| local function open_or_expand_or_dir_up(node, mode, toggle_group, edit_opts) | ||
| local root = node:as(RootNode) | ||
| local dir = node:as(DirectoryNode) | ||
|
|
@@ -468,18 +464,21 @@ function M.toggle_group_empty(node) | |
| end | ||
|
|
||
| ---@param node Node | ||
| function M.preview(node) | ||
| open_or_expand_or_dir_up(node, "preview") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.preview(node, opts) | ||
| open_or_expand_or_dir_up(node, "preview", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
| function M.preview_no_picker(node) | ||
| open_or_expand_or_dir_up(node, "preview_no_picker") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.preview_no_picker(node, opts) | ||
| open_or_expand_or_dir_up(node, "preview_no_picker", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
| function M.edit(node) | ||
| open_or_expand_or_dir_up(node, "edit") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.edit(node, opts) | ||
| open_or_expand_or_dir_up(node, "edit", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
|
|
@@ -498,33 +497,39 @@ function M.replace_tree_buffer(node) | |
| end | ||
|
|
||
| ---@param node Node | ||
| function M.no_window_picker(node) | ||
| open_or_expand_or_dir_up(node, "edit_no_picker") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.no_window_picker(node, opts) | ||
| open_or_expand_or_dir_up(node, "edit_no_picker", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
| function M.vertical(node) | ||
| open_or_expand_or_dir_up(node, "vsplit") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.vertical(node, opts) | ||
| open_or_expand_or_dir_up(node, "vsplit", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
| function M.vertical_no_picker(node) | ||
| open_or_expand_or_dir_up(node, "vsplit_no_picker") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.vertical_no_picker(node, opts) | ||
| open_or_expand_or_dir_up(node, "vsplit_no_picker", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
| function M.horizontal(node) | ||
| open_or_expand_or_dir_up(node, "split") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.horizontal(node, opts) | ||
| open_or_expand_or_dir_up(node, "split", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
| function M.horizontal_no_picker(node) | ||
| open_or_expand_or_dir_up(node, "split_no_picker") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.horizontal_no_picker(node, opts) | ||
| open_or_expand_or_dir_up(node, "split_no_picker", false, opts) | ||
| end | ||
|
|
||
| ---@param node Node | ||
| function M.tab(node) | ||
| open_or_expand_or_dir_up(node, "tabnew") | ||
| ---@param opts nvim_tree.api.node.open.Opts? | ||
| function M.tab(node, opts) | ||
| open_or_expand_or_dir_up(node, "tabnew", false, opts) | ||
| end | ||
|
|
||
| return M | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no
quit_on_openandfocushere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we had some logical or eventing problems with (tab_)drop and decided to exclude them.
#3054 (comment)