Skip to content
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

Path handling problem on Windows #902

Open
ahy-peter-zumtobel opened this issue Sep 12, 2024 · 1 comment
Open

Path handling problem on Windows #902

ahy-peter-zumtobel opened this issue Sep 12, 2024 · 1 comment
Labels

Comments

@ahy-peter-zumtobel
Copy link

Summary:

Newer versions of the extension have a bug in the path handling.

Description:

The value of the variable (path) {asciidoctorconfigdir} starts with a slash (example: '/c:/') so derived path can't be resolved.

Version: since 3.1.6

Environment:
Version: 1.93.0 (user setup)
Commit: 4849ca9bdf9666755eb463db297b69e5385090e3
Date: 2024-09-04T13:02:38.431Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

Reproduce:

  1. Create the files '.asciidoctorconfig.adoc'
  2. Create 'foo.adoc' with following content: {asciidoctorconfigdir}
  3. Look at the preview window. Path is shown as '/c:/...'

Screenshot from 2024-09-12 15-24-35

Related issues

Hints

Suspected corrupt file: asciidoctor-vscode/src/features/AsciidoctorConfig.ts

Suspected corrupt line of code:
72: const asciidoctorConfigParentDirectory = asciidoctorConfig.path.slice(0, asciidoctorConfig.path.lastIndexOf('/')) -> ".path" delivers '/c:/' on Windows.

Temporary workaround: Use version v3.1.5

Possible solution

For this specific case it would be sufficient to replace const asciidoctorConfigParentDirectory = asciidoctorConfig.path.slice(0, asciidoctorConfig.path.lastIndexOf('/')) with const asciidoctorConfigParentDirectory = dir(asciidoctorConfig, workspaceFolderUri).fsPath

This has the intended behavior on Windows as well as on Linux.
But I suspect a general path handling problem to be the root cause.

@ggrossetie
Copy link
Member

.path is the URI and /C:/path/to/directory is a valid URI. The Window file explorer should be able to navigate to file:///C:/path/to/directory/file.txt.

Having said that, we might want to use fsPath (which is not available in VS web) instead of path. Maybe it would be safer to use fsPath only if we are not in a web environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants