fwcd / fwcd/kotlin-language-server
Doesn't work if file path has special characters (specifically [])
- Dominant language
- Kotlin
- Stars
- 2k
- Forks
- 252
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
So I had my project located in `C:\repositories\[other]`, however the language server fails to initialize every time. Looks like it was complaining about an illegal character `[` in output. So I moved my project into `C:\repositories` and it worked.
```
[Error - 3:40:21 PM] Starting client failed
Message: Internal error.
Code: -32603
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:192)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
... 11 more
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 24: file:///c:/repositories/[other]/Kotlin
at java.net.URI.create(Unknown Source)
at org.javacs.kt.util.URIsKt.parseURI(URIs.kt:15)
at org.javacs.kt.KotlinLanguageServer.initialize(KotlinLanguageServer.kt:73)
... 16 more
Caused by: java.net.URISyntaxException: Illegal character in path at index 24: file:///c:/repositories/[other]/Kotlin
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.checkChars(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.(Unknown Source)
... 19 more
```
**To Reproduce**
Steps to reproduce the behavior:
1. Create `.kt` file in a directory path with a `[` somewhere
2. Open with vscode
3. See error
**Expected behavior**
Expected language server to initialize and code completion to work in a directory with special characters (specifically `[` ?)

**^^^**
Above image shows it working (currently only work if the directory path does not contain the `[]` characters
**Extension version**
0.2.18
**Additional context**
I'm on Windows 10 Pro v 10.0.18362 Build 18362
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at org.javacs.kt.util.URIsKt.parseURI in URIs.kt and follow its use from KotlinLanguageServer.initialize at line 73. Reproduce the failure with a Windows project path containing brackets, then verify that initialization and code completion work with those characters present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100