Comments (9)
It’s difficult to say what the correct handling is.
I’ve opened an issue requesting clarification on the handling of negative positions.
from intellij-lsp.
Possibly related, another exception being thrown from the same function in DocumentUtils
java.lang.IndexOutOfBoundsException: Wrong line: 253. Available lines count: 253
at com.intellij.openapi.editor.impl.LineSet.checkLineIndex(LineSet.java:202)
at com.intellij.openapi.editor.impl.LineSet.getLineStart(LineSet.java:187)
at com.intellij.openapi.editor.impl.DocumentImpl.getLineStartOffset(DocumentImpl.java:1020)
at com.intellij.util.DocumentUtil.getLineTextRange(DocumentUtil.java:104)
at com.github.gtache.lsp.utils.DocumentUtils$.$anonfun$LSPPosToOffset$1(DocumentUtils.scala:81)
at com.github.gtache.lsp.utils.DocumentUtils$.$anonfun$LSPPosToOffset$1$adapted(DocumentUtils.scala:78)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:963)
at com.github.gtache.lsp.utils.ApplicationUtils$.computableReadAction(ApplicationUtils.scala:26)
at com.github.gtache.lsp.utils.DocumentUtils$.LSPPosToOffset(DocumentUtils.scala:78)
at com.github.gtache.lsp.editor.EditorEventManager.$anonfun$diagnostics$4(EditorEventManager.scala:443)
at com.github.gtache.lsp.editor.EditorEventManager.$anonfun$diagnostics$4$adapted(EditorEventManager.scala:437)
at scala.collection.Iterator.foreach(Iterator.scala:937)
at scala.collection.Iterator.foreach$(Iterator.scala:937)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
at scala.collection.IterableLike.foreach(IterableLike.scala:70)
at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at com.github.gtache.lsp.editor.EditorEventManager.$anonfun$diagnostics$1(EditorEventManager.scala:437)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
As a side note, this looks to be the same exception seen in #67
from intellij-lsp.
Both should be fixed in #72.
Thanks for all the reports by the way!
from intellij-lsp.
The problem happening in the first trace is happening here still.
pos.getCharacter
has the value -1
.
val lineTextForPosition = if (lineText.nonEmpty) lineText.substring(0, min(lineText.length, pos.getCharacter)) else ""
I would expect that the author of psalm-language-server is using -1
to indicate EOL (which is standard in the language it's written in).
I've checked the LSP spec briefly and I have been unable to determine if negative values are permitted for positions.
from intellij-lsp.
Ok, I looked a bit into psalm and it seems to use phan on the backend for diagnostics, and like you said phan probably uses -1 for this purpose, but I'm not familiar at all with php.
I could add a special case for -1, but all that the LSP specification says is that Position is zero-based and if the character offset is greater than the length of the line, it equals to the length of the line. So It seems to me that sending -1 is invalid.
Have you also checked the VSCode behaviour?
from intellij-lsp.
Great thanks !
from intellij-lsp.
Hey! I created Psalm, let me know if I can help. Psalm doesn't use anything but PHP Parser on the backend. Psalm shouldn't be sending any -1
data - if it does, that's a bug that needs to be fixed in Psalm.
from intellij-lsp.
In LanguageServer/LanguageServer::emitIssues
the value of $end_column - 1
is -1 with the following code snippet:
function test(): int {
return (new Something())
->any();
}
I’m away from my computer but I can provide some more info later if necessary.
from intellij-lsp.
This appears to have been resolved.
from intellij-lsp.
Related Issues (20)
- Auto-completion issue with TextEdit HOT 5
- Quick Documentation does not work for Xtext LSP
- [Feature Request] Temporarily disable LSP
- Ctrl+B keymap
- IllegalArgumentException: Invalid range specified
- Does not work with nvm managed node HOT 3
- Does not work with Bicep.LangServer.exe HOT 1
- Show popup dialog with all definitions when definition request returns more than one location
- Use rust-analyzer instead of RLS for Rust
- Hover doesn't work as expected (always displaying something)
- why is the client encoding spaces in filenames
- server.exit() is never called
- Frequent Error Crashes LSP Support
- LSP is sending way too many `didChange` events, making it unusable
- Is this repo still maintained? HOT 7
- IllegalArgumentException: Invalid range specified: (0, -1) with terraform-ls
- Finding references not working until files are opened HOT 2
- UnsupportedOperationException when using Code Completion
- IndexOutOfBoundsException when writing rust code
- Plugin not found in IntelliJ 2022.3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intellij-lsp.