This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fixes colon escaping on Windows
ClosedPublic

Authored by lh123 on Nov 8 2019, 1:58 AM.

Details

Summary

vscode always escapes the colon on the file uri, which causes the semantic highlighting fails on windows.

fixes: https://github.com/clangd/clangd/issues/176

Diff Detail

Event Timeline

lh123 created this revision.Nov 8 2019, 1:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2019, 1:58 AM
lh123 planned changes to this revision.Nov 8 2019, 2:07 AM

it will cause whitspace escaped problem.

lh123 updated this revision to Diff 228393.Nov 8 2019, 2:43 AM

update diff

lh123 updated this revision to Diff 228397.Nov 8 2019, 2:52 AM

Remove irrelevant files from the patch

lh123 updated this revision to Diff 228405.Nov 8 2019, 3:26 AM
ilya-biryukov added inline comments.Nov 8 2019, 4:34 AM
clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
128 ↗(On Diff #228405)

Could we accept a URI in the highlight (and similar function in highlighting) instead and compare the URIs instead of strings in the Highlighter.applyHighlightings?

i.e. in code:

fileUri : string;
if (e.document.uri.toString() !== fileUri) 
  return;

Could instead be:

fileUri : Uri;
if (e.document.uri.toString() !== fileUri.toString()) 
  return;

This should normalize accordingly and is generally safer and more readable than passing around strings.

lh123 updated this revision to Diff 228421.Nov 8 2019, 5:28 AM

address comment

lh123 marked 2 inline comments as done.Nov 8 2019, 5:30 AM
lh123 added inline comments.
clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
128 ↗(On Diff #228405)

Yes, you are right, I will refactor it.

lh123 marked an inline comment as done and an inline comment as not done.Nov 8 2019, 5:30 AM
lh123 marked an inline comment as not done.
lh123 marked 2 inline comments as done.Nov 8 2019, 5:43 AM
lh123 retitled this revision from [clangd] Fixed colon escaping on Windows to [clangd] Fixes colon escaping on Windows.Nov 8 2019, 6:28 AM
ilya-biryukov accepted this revision.Nov 8 2019, 6:35 AM

LGTM, thanks!
Should I land this patch for you?

If you don't have commit access yet, you could consider applying to get one.

This revision is now accepted and ready to land.Nov 8 2019, 6:35 AM
lh123 added a comment.Nov 8 2019, 6:46 AM

Thanks for your reminder, I have sent an email to apply for commit access, but I don't know how long it will take.

Should I land this patch for you?

Yes, you can land this patch.

Sorry for the delay, forgot to submit on Friday.
Also updated package-lock.json before submitting.

I believe this patch fixes the issue, but we need to update the file test/semantic-highlighting.test.ts), the test "Colorizer groups decorations correctly" is diverged from the actual code, although it is still passed (both string and vscode.Uri have the toString method unfortunately).

@lh123 do you mind doing that?

lh123 added a comment.Nov 11 2019, 6:07 AM

I believe this patch fixes the issue, but we need to update the file test/semantic-highlighting.test.ts), the test "Colorizer groups decorations correctly" is diverged from the actual code, although it is still passed (both string and vscode.Uri have the toString method unfortunately).

@lh123 do you mind doing that?

Sorry, I forgot to update the test case, I have submitted a new patch. D70078