ltex-ls icon indicating copy to clipboard operation
ltex-ls copied to clipboard

LTeX Spell Check does not function

Open SpookyYomo opened this issue 2 years ago • 1 comments

Describe the Bug
Automatic spell-check does not occur, invoking manual spell check (Ctrl + Shift + P > LTeX:Check Current Document > 'Could not check document ....': 'Internal Error.')

Steps to Reproduce

  1. Create a new tex file, type in a functional tex file with intentional mistake, such as
\documentclass[12pt]{article}
\begin{document}
This is an mitsake.
\end{document}
  1. Either Ctrl + S to automatically trigger spell check, or invoke manually as described above.

Expected Behaviour
LTeX picks up on the mistakes. LTeX LS Log:

Jul 12, 2022 11:20:02 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked
FINE: Checking the following text in language 'en-US' via LanguageTool: " This is an mitsake. "
Jul 12, 2022 11:20:02 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Obtained 2 rule matches

(This was obtained on a different computer running ArchLinux and VSCodium)

LTeX Configuration Default, offline installation

LTeX LS Log

Jul 12, 2022 8:50:43 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 1 column 46 path $.sentence
java.util.concurrent.CompletionException: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 1 column 46 path $.sentence
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(Unknown Source)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 1 column 46 path $.sentence
	at com.google.gson.internal.Streams.parse(Streams.java:60)
	at com.google.gson.JsonParser.parseReader(JsonParser.java:85)
	at com.google.gson.JsonParser.parseReader(JsonParser.java:60)
	at com.google.gson.JsonParser.parseString(JsonParser.java:47)
	at org.bsplines.ltexls.settings.HiddenFalsePositive$Companion.fromJsonString(HiddenFalsePositive.kt:21)
	at org.bsplines.ltexls.settings.Settings$Companion.getAllHiddenFalsePositivesFromJson(Settings.kt:399)
	at org.bsplines.ltexls.settings.Settings$Companion.fromJson(Settings.kt:239)
	at org.bsplines.ltexls.server.LtexTextDocumentItem.check(LtexTextDocumentItem.kt:409)
	at org.bsplines.ltexls.server.LtexTextDocumentItem.checkAndGetDiagnostics(LtexTextDocumentItem.kt:295)
	at org.bsplines.ltexls.server.LtexTextDocumentItem.checkAndPublishDiagnostics(LtexTextDocumentItem.kt:272)
	at org.bsplines.ltexls.server.LtexTextDocumentItem.checkAndPublishDiagnosticsWithoutCache(LtexTextDocumentItem.kt:267)
	at org.bsplines.ltexls.server.LtexWorkspaceService.executeCheckDocumentCommand$lambda-0(LtexWorkspaceService.kt:127)
	... 8 more
Caused by: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 1 column 46 path $.sentence
	at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1562)
	at com.google.gson.stream.JsonReader.readEscapeCharacter(JsonReader.java:1553)
	at com.google.gson.stream.JsonReader.nextQuotedValue(JsonReader.java:1013)
	at com.google.gson.stream.JsonReader.nextString(JsonReader.java:814)
	at com.google.gson.internal.bind.TypeAdapters$27.read(TypeAdapters.java:663)
	at com.google.gson.internal.bind.TypeAdapters$27.read(TypeAdapters.java:684)
	at com.google.gson.internal.bind.TypeAdapters$27.read(TypeAdapters.java:655)
	at com.google.gson.internal.Streams.parse(Streams.java:48)
	... 19 more

Environment

  • OS: OpenSUSE 15.4 - Linux <hostname> 5.14.21-150400.22-default #1 SMP PREEMPT_DYNAMIC Wed May 11 06:57:18 UTC 2022 (49db222) x86_64 x86_64 x86_64 GNU/Linux
  • VSCode: 1.69.0
  • LaTeX Workshop: 8.27.2
  • LTeX-ls: Offline version 13.1.0 (Linux) (29 Nov 2021 13.1 release on vscode-ltex repo)

SpookyYomo avatar Jul 12 '22 13:07 SpookyYomo

I figured out the reason for my case. I added new rules in ltex.hiddenFalsePositives manually, however,

  • there was an escaping mistake (quadro-backslashs \\\\ should correspond to one \ in e.g. \s)
  • and a regex-dialect issue (whether to escape {).

After fixing them the problem is solved.

jagd avatar Aug 13 '23 20:08 jagd