File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -175,12 +175,10 @@ handle_reveal = function(args, state)
175175 if cwd == nil then
176176 cwd = manager .get_cwd (state )
177177 end
178- if args .reveal_force_cwd then
179- if not utils .is_subpath (cwd , path ) then
180- args .dir , _ = utils .split_path (path )
181- do_show_or_focus (args , state , true )
182- return
183- end
178+ if args .reveal_force_cwd and not utils .is_subpath (cwd , path ) then
179+ args .dir , _ = utils .split_path (path )
180+ do_show_or_focus (args , state , true )
181+ return
184182 elseif not utils .is_subpath (cwd , path ) then
185183 -- force was not specified, so we need to ask the user
186184 cwd , _ = utils .split_path (path )
Original file line number Diff line number Diff line change 11local utils = {}
22
33local Path = require (" plenary.path" )
4- local testdir = Path :new (vim .env .TMPDIR or " /tmp" , " neo-tree-testing" ):absolute ()
4+ -- Resolve for two reasons.
5+ -- 1. Follow any symlinks which make comparing paths fail. (on macOS, TMPDIR can be under /var which is symlinked to
6+ -- /private/var)
7+ -- 2. Remove any double separators (on macOS TMPDIR can end in a trailing / which absolute doesn't remove, this should
8+ -- be coverted by https://github.com/nvim-lua/plenary.nvim/issues/330).
9+ local testdir = vim .fn .resolve (Path :new (vim .env .TMPDIR or " /tmp" , " neo-tree-testing" ):absolute ())
510
611local function rm_test_dir ()
712 if vim .fn .isdirectory (testdir ) == 1 then
Original file line number Diff line number Diff line change 1+ local Path = require (' plenary.path' )
12local util = require (" tests.helpers.util" )
23local verify = require (" tests.helpers.verify" )
34local config = require (" neo-tree" ).config
@@ -50,14 +51,20 @@ describe("Command", function()
5051 verify .buf_name_is (testfile )
5152 end )
5253
53- it (" `:Neotree current reveal_force_cwd reveal_file=xyz` should reveal file current window" , function ()
54+ it (" `:Neotree current reveal_force_cwd reveal_file=xyz` should reveal file current window if cwd is not a parent of file " , function ()
5455 vim .cmd (" cd ~" )
55- vim .cmd (" tcd ~" )
56- vim .cmd (" lcd ~" )
5756 local testfile = fs .lookup [" deepfile2" ].abspath
5857 local cmd = " Neotree current reveal_force_cwd reveal_file=" .. testfile
5958 run_in_current_command (cmd , testfile )
6059 end )
60+
61+ it (" `:Neotree current reveal_force_cwd reveal_file=xyz` should reveal file current window if cwd is a parent of file" , function ()
62+ local testfile = fs .lookup [" deepfile2" ].abspath
63+ local testfile_dir = Path :new (testfile ):parent ().filename
64+ vim .cmd (string.format (" cd %s" , testfile_dir ))
65+ local cmd = " Neotree current reveal_force_cwd reveal_file=" .. testfile
66+ run_in_current_command (cmd , testfile )
67+ end )
6168 end )
6269
6370 util .teardown_test_fs ()
You can’t perform that action at this time.
0 commit comments