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
Relative patterns should use URIs and not fsPath for pattern matching #99938
Comments
Can you check if it works when not having the |
@jrieken Yes, the codelens works if the document selector only has |
Hm... The pattern specifies an absolute path and I wonder if that's the problem. On what machine should that path exist? On the local or remote machine? I'd assume they have different folder hierarchies. Also, know that you can create a Line 1880 in 5b35173
|
The path is on the remote machine. Actually you can just try with the code lens extension sample to repro that. |
Ok, that explains it. The path will be evaluated on the UI side, e.g. inside the render we need to make the decision if code lens providers apply or not |
So take the WSL as an example, VS Code will evaluate the file's real path (which is a Windows path) to If that is the case, I think I need to cache the pattern and compare it inside the CodeLensProvider, instead of using the DocumentSelector. |
Unsure about WSL and path shapes... Maybe @aeschli can help. |
This should work. The code lens engine should see the document as |
When using this toy extension and @aeschli test resolver I get it to work (in local and remote) vscode.languages.registerCodeLensProvider({
scheme: 'file',
pattern: new vscode.RelativePattern('/Users/jrieken/Code/_samples/devfest/foo/', '**/*.txt')
}, new class implements vscode.CodeLensProvider {
onDidChangeCodeLenses?: vscode.Event<void> | undefined;
provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken) {
console.log('I have been called!')
return [];
}
}) @jdneo From your remote test file, can you invoke |
Hi @jrieken I still cannot see the Code Lens in Remote: WSL. Is there anything I missed? |
@jdneo I believe this could be due to the const selector: DocumentSelector = {
pattern: new RelativePattern(workspace.workspaceFolders![0], '**/*.txt')
}; So that you pick the workspace folder and not have to specify any URI. |
@bpasero This actually makes me more confused. If I'm using And you can see the first picture I attached. If the document selector has only the Seems that it's not because of the file scheme, but the |
@jdneo yeah not sure, in principle you should never write the pattern as file path but use that workspace folder if you want to point to it. I will defer to @jrieken or @aeschli to explain where this language selector is being evaluated, the code is here:
But I am not sure if the file path that goes there is of One theory I have is that maybe the use of |
Upon further investigation, I figured that this seems to be related to the The following works for me:
It looks like we are having a remote WSL path that will have backslashes when vscode/src/vs/base/common/glob.ts Line 334 in b8f63e9
I think the only solution here would be to push In any case, using the workspace folder is the best way out still. |
What if we want to resolve code lenses in part of the folders in the workspace? I tried to move the file path to the |
Yes, on windows |
Yeah, though this would break any existing code that defines the path with backslashes. We could document this though, e.g. always require POSIX paths for relative glob patterns. |
Not sure that I understand correctly? Do you mean |
@jrieken yeah so glob patterns always requires POSIX paths (though we internally treat I can do a fix where I support both slash and backslash, maybe that is the safest option. |
Tested in latest Insider and the Code Lens shows as expected. Thank you for fixing this. :) |
Version: 1.46.0 (system setup)
Commit: a5d1cc2
Date: 2020-06-10T09:03:20.462Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363
Steps to Reproduce:
Using the code lens sample: https://github.com/microsoft/vscode-extension-samples/tree/master/codelens-sample
Add a
DocumentSelector
when register the code lens providerOpen the folder which containing the file pattern in Remote (i.e. WSL).
The
CodeLensProvider#provideCodeLenses()
won't get hitted.The text was updated successfully, but these errors were encountered: