microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.64k stars 28.67k forks source link

Test: canonical URIs #98861

Closed bpasero closed 4 years ago

bpasero commented 4 years ago

https://github.com/microsoft/vscode/issues/93368

Complexity: 4 Authors: @jrieken @bpasero

Create Issue


Canonical URIs respect the file system providers case-sensitivity capability. Given a file system that is case-insensitive (e.g. macOS, Windows in most cases), the first creator of a canonical URI defines its casing and subsequent URIs of different casing will have the same canonical form.

The following is an example where canonical URIs help a lot:

With canonical URIs, the user defined the canonical URI to be path/someFile.c when opening it. Even though the output is using path/somefile.c form, the markers are being created with the path/someFile.c path and thus match. You will only end up with a single editor opening, not two.

Canonical URIs have been adopted in the following places:

Test

chrmarti commented 4 years ago

@bpasero With markers you mean TextEditor.setDecorations() in the extension API?

Edit: More likely vscode.languages.createDiagnosticCollection().

jrieken commented 4 years ago

Yeah, the API is using the diagnostic collection. Something like this is what I have

const diag = vscode.languages.createDiagnosticCollection('muhaha');

    for (let path of [
        '/Users/jrieken/Code/_samples/devfest/foo/TEST.less',
        '/Users/jrieken/Code/_samples/devfest/foo/TEST.ts'
    ]) {
        const uri = vscode.Uri.file(path);
        const d = new vscode.Diagnostic(new vscode.Range(0, 0, 1, 0), 'casing matters', vscode.DiagnosticSeverity.Information);
        diag.set(uri, [d])
    }
chrmarti commented 4 years ago

Thanks. Also found a nice sample: https://github.com/microsoft/vscode-extension-samples/tree/master/diagnostic-related-information-sample