valentjn / ltex-ls

LTeX Language Server: LSP language server for LanguageTool :mag::heavy_check_mark: with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
717 stars 33 forks source link

StringIndexOutOfBoundsException #303

Open ZeliTheZealot opened 2 months ago

ZeliTheZealot commented 2 months ago

Describe the bug StringIndexOutOfBoundsException

Steps to reproduce Run the command (base) computer_name:~ username$ ltex-ls-16.0.0/bin/ltex-cli "filename.tex"

Expected behavior Not sure. It is my first time running it.

Sample document It is very long and confidential unfortunately. I can say that it is based on this template.

``` REPLACE_THIS_WITH_SAMPLE_DOCUMENT ```

LTeX configuration No configuration.

``` REPLACE_THIS_WITH_LTEX_CONFIGURATION ```

LTeX LS log See below

``` filename.tex:51:28: info: Possible typo: you repeated a whitespace [WHITESPACE_RULE] java.lang.StringIndexOutOfBoundsException: begin 27, end 165, length 37 at java.base/java.lang.String.checkBoundsBeginEnd(Unknown Source) at java.base/java.lang.String.substring(Unknown Source) at org.bsplines.lspcli.client.Checker$Companion.printDiagnostic(Checker.kt:185) at org.bsplines.lspcli.client.Checker$Companion.access$printDiagnostic(Checker.kt:135) at org.bsplines.lspcli.client.Checker.checkFile(Checker.kt:129) at org.bsplines.lspcli.client.Checker.check(Checker.kt:66) at org.bsplines.lspcli.client.Checker.check(Checker.kt:39) at org.bsplines.lspcli.LspCliLauncher.call(LspCliLauncher.kt:174) at org.bsplines.lspcli.LspCliLauncher$Companion.main(LspCliLauncher.kt:212) at org.bsplines.lspcli.LspCliLauncher.main(LspCliLauncher.kt) ```

Version information

Additional context/information Nothing at the moment.

kmccurley commented 3 weeks ago

I'm finding ltex-ls to be unusable because it throws an exception on over half of the inputs that I've tried it on (my inputs are from the pipeline of a journal and supplied by the authors). I'm only using it from the command line on Ubuntu 22.04.4. A sample stack trace is:

java.lang.StringIndexOutOfBoundsException: begin 24, end 26, length 25
    at java.base/java.lang.String.checkBoundsBeginEnd(Unknown Source)
    at java.base/java.lang.String.substring(Unknown Source)
    at org.bsplines.lspcli.client.Checker$Companion.printDiagnostic(Checker.kt:185)
    at org.bsplines.lspcli.client.Checker$Companion.access$printDiagnostic(Checker.kt:135)
    at org.bsplines.lspcli.client.Checker.checkFile(Checker.kt:129)
    at org.bsplines.lspcli.client.Checker.check(Checker.kt:66)
    at org.bsplines.lspcli.client.Checker.checkDirectory(Checker.kt:75)
    at org.bsplines.lspcli.client.Checker.check(Checker.kt:60)
    at org.bsplines.lspcli.client.Checker.check(Checker.kt:39)
    at org.bsplines.lspcli.LspCliLauncher.call(LspCliLauncher.kt:174)
    at org.bsplines.lspcli.LspCliLauncher$Companion.main(LspCliLauncher.kt:212)
    at org.bsplines.lspcli.LspCliLauncher.main(LspCliLauncher.kt)
Jun 16, 2024 11:49:59 AM org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor run
SEVERE: java.io.IOException: Stream closed