-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 conversion for windows and posix file systems #10591
Conversation
6822bf1
to
da93ba2
Compare
Thanks @msujew At the moment we have a workaround and also had the internal feature that needed the fix/workaround reduced in priority |
@bd82 Not a problem, I actually tackled this issue due to something different that I noticed, it just also fixes the issue you were experiencing ;) |
this.resource = this.contextKeyService.createKey<Uri>('resource', undefined); | ||
this.resourceSchemeKey = this.contextKeyService.createKey<string>('resourceScheme', undefined); | ||
this.resourceFileName = this.contextKeyService.createKey<string>('resourceFilename', undefined); | ||
this.resourceExtname = this.contextKeyService.createKey<string>('resourceExtname', undefined); | ||
this.resourceLangId = this.contextKeyService.createKey<string>('resourceLangId', undefined); | ||
this.resourceDirName = this.contextKeyService.createKey<string>('resourceDirName', undefined); | ||
this.resourcePath = this.contextKeyService.createKey<string>('resourcePath', undefined); | ||
this.isPosix = await this.applicationService.getBackendOS() !== OS.Type.Windows; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msujew, it looks like you could import isWindows
from core/src/common/os.ts
rather than relying on the ApplicationServer. That would give you what you need synchronously rather than waiting on a Promise
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except isWindows
will give the OS of the running browser here, and not the remote backend? Not sure which one makes more sense here, but they aren't the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colin-grant-work Exactly as @paul-marechal is saying, in this case we need the backend OS, since it specifies the string format of all file paths (forward- vs. backward-slashes, drive letters in front, etc.). The whole reason why this bug exists, is that the frontend and backend might convert the same URI into different strings, which would then result in a mismatch of the when
context property of commands.
In particular, when we have something like resourcePath in ext:pkgJsonWithTestScript
as a context, the monaco frontend on windows will convert the current resourcePath
into something like \user\settings.json
, while the posix backend path is actually using /user/settings.json
. Monaco will then perform an in
check on the ext:pkgJsonWithTestScript
object, which will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose then I wonder whether we shouldn't make retrieving information about the backend OS part of the pre-load startup routine so that we can then access it synchronously from inside the application? That would alleviate some of my anxiety about race conditions.
da93ba2
to
2dc1c78
Compare
@colin-grant-work Care to take another look at this? I also opened #10830 to keep track of all misusage of |
@msujew, I've got a brand-new Windows system I should be able to test this on, so I'll take another look today :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes work for me in various combinations of Linux and Windows servers and browsers. My only comment is about the asynch retrieval of the backend OS, which is probably fine but could potentially go wrong. If it's impractical to make the check synchronous while the application is running, then I'm fine with the current implementation.
85b7178
to
2616ae7
Compare
@colin-grant-work Alright, I did some larger refactoring for |
@msujew, I missed this review request - sorry; I'll take a look today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functionality continues to work, and the move to a preloader
makes this code cleaner, cleans up a few other areas, and opens up a lot of possibilities (e.g. preferences) so that's a definite 👍. One or two minor things that you can address or leave, as you choose.
2616ae7
to
4491930
Compare
4491930
to
2f65949
Compare
What it does
Closes #10552
Enables to convert URIs in the frontend to a file system path independent of the frontend OS (unlike
vscode-uri.fsPath
). This can be used to display backend paths, such as the file paths of opened editors in thetitle
property.How to test
This one is a bit difficult to test. The easiest setup would be to run Theia on a Unix machine and access the browser version on Windows.
title
(hover display) of the file node should always display the correct backend path. I.e.C:\file\to\path.txt
on windows and/path/to/file.txt
on Unix.package.json
files which contain adependencies
section. TheInstall Dependencies
menu entry should be visible.Review checklist
Reminder for reviewers