-
Notifications
You must be signed in to change notification settings - Fork 197
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
implemented changes intially created by @daog1 and addresses the comm… #1016
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,14 @@ M.copy = function(state) | |
cc.copy(state, redraw) | ||
end | ||
|
||
M.copy_path = function(state) | ||
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. I don't think this is needed at all because there is a
call at the end of the file, which will add this command anyhow. This pattern of wrapping common commands is only needed when we need to alter the common command in some way, such as by adding a |
||
cc.copy_path(state) | ||
end | ||
|
||
M.copy_abspath = function(state) | ||
cc.copy_abspath(state) | ||
end | ||
|
||
M.move = function(state) | ||
cc.move(state, redraw) | ||
end | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -481,6 +481,34 @@ M.copy = function(state, callback) | |||||||||
fs_actions.copy_node(node.path, nil, callback, using_root_directory) | ||||||||||
end | ||||||||||
|
||||||||||
---Copies a node relative path to clipboard. | ||||||||||
---@param state table The state of the source | ||||||||||
M.copy_path = function(state) | ||||||||||
local node = state.tree:get_node() | ||||||||||
if node.type == "message" then | ||||||||||
return | ||||||||||
end | ||||||||||
local pwdpath = state.path | ||||||||||
local content = node.path | ||||||||||
Comment on lines
+491
to
+492
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. Since this is a common command, there's no guarantee that either of these exist for all sources.
Suggested change
|
||||||||||
local rpath = "." .. string.sub(content, string.len(pwdpath) + 1) | ||||||||||
vim.fn.setreg("+", rpath) | ||||||||||
vim.fn.setreg('"', rpath) | ||||||||||
log.info("copy " .. node.name .. " path to clipboard") | ||||||||||
end | ||||||||||
|
||||||||||
---Copies a node absolute path to clipboard. | ||||||||||
---@param state table The state of the source | ||||||||||
M.copy_abspath = function(state) | ||||||||||
local node = state.tree:get_node() | ||||||||||
if node.type == "message" then | ||||||||||
return | ||||||||||
end | ||||||||||
local content = node.path | ||||||||||
vim.fn.setreg("+", content) | ||||||||||
vim.fn.setreg('"', content) | ||||||||||
log.info("copy " .. node.name .. "abs path to clipboard") | ||||||||||
end | ||||||||||
|
||||||||||
---Moves a node to a new location, using typed input. | ||||||||||
---@param state table The state of the source | ||||||||||
---@param callback function The callback to call when the command is done. Called with the parent node as the argument. | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,14 @@ M.copy = function(state) | |
cc.copy(state, utils.wrap(refresh, state)) | ||
end | ||
|
||
M.copy_path = function(state) | ||
cc.copy_path(state) | ||
end | ||
|
||
M.copy_abspath = function(state) | ||
cc.copy_abspath(state) | ||
end | ||
|
||
Comment on lines
+35
to
+42
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. These can be deleted as well. |
||
---Marks node as copied, so that it can be pasted somewhere else. | ||
M.copy_to_clipboard = function(state) | ||
cc.copy_to_clipboard(state, utils.wrap(redraw, state)) | ||
|
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.
The only problem here is that the commands are defined at the global level so that it applies to all sources, but it is not really a command that will work universally. It should be mapped within the
filesystem
andbuffers
commands instead.It also makes sense to use it in the
git_status
source.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.
This is correct. For example, Netman explodes when you navigate to it's Neo-tree source because I don't have these commands implemented yet. IMO they should not be "common".
Or if they are, this release needs to be slow walked as this should be considered a "Breaking Change" for 3rd party developers using Neo-tree.
That said, I really like this feature, so whatever command is decided on, I will implement it in Netman. But the fact that this causes an error on source load means this is IMO a breaking change.
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.
Forgive my ignorance, and would you explain it in more detail,thx alot