-
Notifications
You must be signed in to change notification settings - Fork 251
fix: Leading slashes of spaces in paths on Windows when opening files #1077
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
Conversation
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
miversen33
approved these changes
Jul 30, 2023
I wouldn't have expected this to work on linux but it sure does! Nice catch and good fix :) Tested with the below config (for future reference) -- Minimal configuration
-- mini.lua
-- Use with the --clean -u flags. EG nvim --clean -u mini.lua
-- This config will create a temp directory and will blow away that temp directory
-- everytime this configuration is loaded. Great for simulating a new installation
-- of a plugin
-- Setting some basic vim options
-- Some junk because I am sick of formatting tables in print
local _print = _G.print
local clean_string = function(...)
local args = { n = select("#", ...), ... }
local formatted_args = {}
for i=1, args.n do
local item = select(i, ...)
if not item then item = 'nil' end
local t_type = type(item)
if t_type == 'table' or t_type == 'function' or t_type == 'userdata' then
item = vim.inspect(item)
end
table.insert(formatted_args, item)
end
return table.concat(formatted_args, ' ')
end
_G.print = function(...)
_print(clean_string(...))
end
vim.opt.mouse = 'a'
vim.opt.termguicolors = true
-- If you want to play around with this, you can set the do_clean
-- variable to false. This will allow changes made to
-- underlying plugins to persist between sessions, while
-- still keeping everything in its own directory so
-- as to not affect your existing neovim installation.
--
-- Setting this to true will result in a fresh clone of
-- all modules
local do_clean = true
local sep = vim.loop.os_uname().sysname:lower():match('windows') and '\\' or '/' -- \ for windows, mac and linux both use \
local mod_path = string.format("%s%sclean-test%s", vim.fn.stdpath('cache'), sep, sep)
if vim.loop.fs_stat(mod_path) and do_clean then
print("Found previous clean test setup. Cleaning it out")
-- Clearing out the mods directory and recreating it so
-- you have a fresh run everytime
vim.fn.delete(mod_path, 'rf')
end
vim.fn.mkdir(mod_path, 'p')
local modules = {
{'nvim-lua/plenary.nvim'},
{'nvim-tree/nvim-web-devicons'},
{'MunifTanjim/nui.nvim'},
{'wizcas/neo-tree.nvim', branch='1076-win-space-in-path', mod = 'neo-tree'},
}
for _, module in ipairs(modules) do
local repo = module[1]
local branch = module.branch
local module_name = repo:match('/(.*)')
local module_path = string.format('%s%s%s', mod_path, sep, module_name)
if not vim.loop.fs_stat(module_name) then
-- The module doesn't exist, download it
local cmd = {
'git',
'clone'
}
if branch then
table.insert(cmd, '--branch')
table.insert(cmd, branch)
end
table.insert(cmd, string.format('https://github.com/%s', repo))
table.insert(cmd, module_path)
vim.fn.system(cmd)
local message = string.format("Downloaded %s", module_name)
if branch then
message = string.format("%s on branch %s", message, branch)
end
print(message)
end
vim.opt.runtimepath:append(module_path)
end
print("Finished installing plugins. Beginning Setup of plugins")
for _, module in ipairs(modules) do
if module.mod then
print(string.format("Loading %s", module.mod))
local success, err = pcall(require, module.mod)
if not success then
print(string.format("Failed to load module %s", module.mod))
error(err)
end
end
end
-- --> Do you module setups below this line <-- --
local neo_tree = require("neo-tree")
neo_tree.setup(
{
sources = {
"filesystem",
},
filesystem = {
follow_current_file = true,
},
}
)
-- --> Do your module setups above this line <-- --
print("Creating Environment to emulate #1076")
vim.fn.delete('./test', 'rf')
vim.fn.mkdir('./test/outer/(inner)', 'p')
vim.fn.mkdir('./test/test path/', 'p')
vim.fn.mkdir('./test/nested dir/', 'p')
vim.fn.mkdir('./test/(inner)', 'p')
vim.fn.mkdir('./test/ leading/', 'p')
vim.fn.mkdir('./test/trailing /', 'p')
local h = nil
h = io.open('./test/outer/(inner)/file.txt', 'w')
h:write("file.txt content\n")
h:close()
h = io.open('./test/outer/test.txt', 'w')
h:write("test.txt content\n")
h:close()
h = io.open('./test/test path/test.txt', 'w')
h:write("test path.txt content\n")
h:close()
h = io.open('./test/nested dir/test.txt', "w")
h:write("test nested dir test.txt content\n")
h:close()
h = io.open('./test/(inner)/test.txt', "w")
h:write("test inner test.txt content\n")
h:close()
h = io.open("./test/ leading/test.txt", "w")
h:write("test leading test.txt content\n")
h:close()
h = io.open("./test/trailing /test.txt", 'w')
h:write("test trailing test.txt content\n")
h:close()
vim.api.nvim_command('cd ./test/')
print("Created environment")
print("Completed minimal setup! Execute :Neotree to get started")
|
miversen33
approved these changes
Jul 30, 2023
@cseickel could you please review and approve? |
cseickel
approved these changes
Jul 31, 2023
Thanks for testing @miversen33! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1076
@miversen33 Could you please take a look at this fix? It's a subsequent fix of the Windows path adaption since PR #1023.
I've tested on my side for these test cases and all of them have passed:
d:\test path\test.txt
d:\test\nested dir\test.txt
d:\test\(inner)\test.txt
<-- regression test for 889 windows path escape #1023d:\test\ leading\test.txt
d:\test\trailing \test.txt