Fix opening code via command line using relative paths#3150
Fix opening code via command line using relative paths#3150joaomoreno merged 2 commits intomicrosoft:masterfrom Tyriar:3127_fix_open_relative_path
Conversation
Opening code using `code ..`, `code ../..` was opening the wrong directory since trailing '.' characters were being trimmed by the launch code. Fixes #3127
|
I am really afraid of touching this code, and @bpasero is out. No idea why this code is there... makes very little sense to me. E.g. what happens if we tried to open a folder with a dot at the end ( Any way, @Tyriar can you give me more details here? Is this because the new launcher script behaves differently? Did you test this on Linux, OSX and Windows? |
|
Might be best to wait for @bpasero if you're concerned. I've only tested on Linux, I don't see why trailing |
|
Not being able to open What do you think? |
|
Sounds good to me, I'll just remove it then. |
|
👍 |
Fix opening code via command line using relative paths
|
@Tyriar but if the condition is to only trim "." if there is a non-dot before the dot, you would still be able to open "." and ".."? |
|
@bpasero normalizing the path beforehand would transform |
|
@Tyriar I would trim all "." from a path on windows, but I see the issue. Why would someone actually type the full path and append ".." at the end? Is that a use case? |
|
@bpasero regardless, it should still open the path that's provided, not the path with
Not doing so will likely result in another issue down the track. |
|
@Tyriar makes sense, I am also easy leaving it without the trimming code. |
|
I pushed another fix for #1579, I omitted the dir check, not really needed after normalizing. Needs to be verified on Windows. |
|
Thanks 👍 |
|
@Tyriar with your change, opening "." or ".." on windows will result in the unexpected behaviour as before because path.normalize() will not change "." or ".." to anything. |
|
@bpasero would joining with cwd because normalizing fix the issue? path = path.join(process.cwd(), path) |
|
Well it might but you can only do so if the path is relative. |
Opening code using
code ..,code ../..was opening the wrong directorysince trailing '.' characters were being trimmed by the launch code.
Fixes #3127
@bpasero I'm assuming that the trimming was added for Windows, just wanted to make sure that was the intent. Or can we remove it?