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

lsp: URI/Path handling fixes #1419

Merged
merged 1 commit into from
Feb 25, 2025
Merged

Conversation

charlieegan3
Copy link
Member

There was an issue where a colon in a file name would cause the wrong path to be generated from a URI and vice versa. This caused the server to reload the file every second as it was missing, but really it was just registered under the wrong URI in the cache.

Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM with two suggested fixes.

if client == clients.IdentifierVSCode {
// Convert Windows path separators to Unix separators
path = filepath.ToSlash(path)
drivePattern := regexp.MustCompile(`^([A-Za-z]):`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this a package level var to avoid it being compiled with each call.

if strings.Contains(path, ":") || strings.Contains(path, "%3A") {
path = strings.Replace(path, "%3A", ":", 1)
path = strings.TrimPrefix(path, "/")
drivePattern := regexp.MustCompile(`^([A-Za-z])(%3[aA]|:)`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@charlieegan3
Copy link
Member Author

Thanks, that makes sense! Have fixed now.

There was an issue where a colon in a file name would cause the wrong
path to be generated from a URI and vice versa. This caused the server
to reload the file every second as it was missing, but really it was
just registered under the wrong URI in the cache.

Signed-off-by: Charlie Egan <[email protected]>
@charlieegan3 charlieegan3 merged commit 25bde5a into StyraInc:main Feb 25, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants