vscode icon indicating copy to clipboard operation
vscode copied to clipboard

"Open link" command fails to follow file url with line number if given file is outside of directory opened by vscode

Open gavvvr opened this issue 1 year ago • 0 comments

Does this issue occur when all extensions are disabled?: Yes

VS Code version: Code - Insiders 1.95.0-insider (c85acdad6b679973c79b01a38afa91448c705c1c, 2024-10-18T07:31:27.077Z) OS version: Darwin arm64 23.6.0 Modes:

System Info
Item Value
CPUs Apple M2 Pro (10 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 3, 3
Memory (System) 16.00GB (0.31GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none

Steps to Reproduce:

Use minimal attached files structure: example.zip

  1. You will need to the following directories structure
├── index_outside_of_working_dir.js
└── vscode-working-directory
    ├── error.log
    └── index.js
  1. The content of both .js files is the same and actually, doesn't matter for demonstration:
function greet(){
  return "Hello, World!";
}
  1. The content of error.log should be:
Error: Some error outsie of project's working directory
    at greet (file:///Users/User/Documents/sandboxes/vscode-problem/index_outside_of_working_dir.js:2:10) <--- attempts to create new file with numbers in it's name ❌
    at greet (file:///Users/User/Documents/sandboxes/vscode-problem/index_outside_of_working_dir.js:2) <--- attempts to create new file with numbers in it's name ❌
    at greet (file:///Users/User/Documents/sandboxes/vscode-problem/index_outside_of_working_dir.js) <---- no problems ✅

Error: Some error within working directory
    at greet (file:///Users/User/Documents/sandboxes/vscode-problem/vscode-working-directory/index.js:2:10) <---- no problems ✅
    at greet (file:///Users/User/Documents/sandboxes/vscode-problem/vscode-working-directory/index.js:2) <---- no problems ✅
    at greet (file:///Users/User/Documents/sandboxes/vscode-problem/vscode-working-directory/index.js) <---- no problems ✅

Replace /Users/User/Documents/sandboxes/vscode-problem/ with your own absolute path

  1. Open vscode-working-directory in vscode and then open error.log. "Open link" action will fail to navigate to .js file outside of currently opened directory if there are also line numbers following the absolute path of the file ❌ Instead, vscode will offer to create not existing .js file with line numbers in its name.
  2. Now open an upper directory (/vscode-problem) in vscode and the problem is gone, because now index_outside_of_working_dir.js belongs to currently opened directory ✅

gavvvr avatar Oct 19 '24 09:10 gavvvr