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

Inline Math (text between a single dollar sign) causes LTeX to stop working #855

Open
attiliocn opened this issue Oct 3, 2023 · 3 comments
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label)

Comments

@attiliocn
Copy link

Describe the bug
The use of inline math in a .tex document "shuts down" LTeX. This problem seems to occur only when the inline math is not preceded by any character.

Steps to reproduce

This document should be sufficient to demonstrate the problem.

\documentclass[12pt]{report}
\begin{document}

Lorem ipsum$\Delta$ dolor sit amet, consectetur adipiscing elit. 

Lorem ipsum $\Delta$ dolor sit amet, consectetur adipiscing elit. 

\end{document}

If both lines containing Lorem ipsum are kept uncommented, then the following server log is obtained and VSCode does not show any highlighted word.

image

Oct 03, 2023 10:59:28 AM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked
FINE: Checking the following text in language 'pt-BR' via LanguageTool: " \n\nLorem ipsumDummy0 dolor sit amet, consectetur adipiscing elit.\n\nLorem ipsum Dummy1 dolor sit amet"... (truncated to 100 characters)
Oct 03, 2023 10:59:29 AM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
SEVERE: LanguageTool failed. The following exception occurred:
java.lang.RuntimeException: java.lang.RuntimeException: Could not check sentence (language: Portuguese (Brazil)): <sentcontent>Lorem ipsum Dummy1 dolor sit amet, consectetur adipiscing elit.

</sentcontent>
	at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:1230)
	at org.languagetool.JLanguageTool.checkInternal(JLanguageTool.java:970)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:900)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:882)
	at org.languagetool.JLanguageTool.check(JLanguageTool.java:869)
	at org.bsplines.ltexls.languagetool.LanguageToolJavaInterface.checkInternal(LanguageToolJavaInterface.kt:112)
	at org.bsplines.ltexls.languagetool.LanguageToolInterface.check(LanguageToolInterface.kt:22)
	at org.bsplines.ltexls.server.DocumentChecker.checkAnnotatedTextFragment(DocumentChecker.kt:138)
	at org.bsplines.ltexls.server.DocumentChecker.checkAnnotatedTextFragments(DocumentChecker.kt:91)
	at org.bsplines.ltexls.server.DocumentChecker.check(DocumentChecker.kt:279)
	at org.bsplines.ltexls.server.LtexTextDocumentItem.check(LtexTextDocumentItem.kt:413)
	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.LtexTextDocumentItem.checkAndPublishDiagnosticsWithoutCache$default(LtexTextDocumentItem.kt:266)
	at org.bsplines.ltexls.server.LtexTextDocumentService.didChange$lambda-3(LtexTextDocumentService.kt:227)
	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: java.lang.RuntimeException: Could not check sentence (language: Portuguese (Brazil)): <sentcontent>Lorem ipsum Dummy1 dolor sit amet, consectetur adipiscing elit.

</sentcontent>
	at org.languagetool.JLanguageTool$TextCheckCallable.getOtherRuleMatches(JLanguageTool.java:1883)
	at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1765)
	at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1736)
	at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:1226)
	... 21 more
Caused by: java.lang.RuntimeException: fromPos (134) must be less than toPos (134) for match: <sentcontent>HUNSPELL_RULE:12-17:Encontrado possível erro de ortografia.</sentcontent>
	at org.languagetool.rules.RuleMatch.setOffsetPosition(RuleMatch.java:326)
	at org.languagetool.JLanguageTool.adjustRuleMatchPos(JLanguageTool.java:1345)
	at org.languagetool.JLanguageTool$TextCheckCallable.getOtherRuleMatches(JLanguageTool.java:1856)
	... 24 more

However, if the second Lorem Ipsum is commented, then the following log is obtained and LTeX works as expected.

image

Oct 03, 2023 11:04:38 AM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked
FINE: Checking the following text in language 'pt-BR' via LanguageTool: " \n\nLorem ipsumDummy0 dolor sit amet, consectetur adipiscing elit.\n\n"
Oct 03, 2023 11:04:38 AM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Obtained 8 rule matches

Expected behavior
I expect that the Grammar/Spell check does not stops because there is an inline math present in the text.

Sample document

\documentclass[12pt]{report}
\begin{document}

Lorem ipsum$\Delta$ dolor sit amet, consectetur adipiscing elit. 

Lorem ipsum $\Delta$ dolor sit amet, consectetur adipiscing elit. 

\end{document}

LTeX configuration

{
  "enabled": [
    "latex",
    "markdown"
  ],
  "language": "pt-BR",
  "dictionary": {},
  "disabledRules": {},
  "enabledRules": {},
  "hiddenFalsePositives": {},
  "bibtex": {
    "fields": {}
  },
  "latex": {
    "commands": {
      "\\autocite{}": "ignore"
    },
    "environments": {}
  },
  "markdown": {
    "nodes": {}
  },
  "configurationTarget": {
    "dictionary": "workspaceFolderExternalFile",
    "disabledRules": "workspaceFolderExternalFile",
    "hiddenFalsePositives": "workspaceFolderExternalFile"
  },
  "additionalRules": {
    "enablePickyRules": false,
    "motherTongue": "pt-BR",
    "languageModel": "",
    "neuralNetworkModel": "",
    "word2VecModel": ""
  },
  "languageToolHttpServerUri": "",
  "languageToolOrg": {
    "username": "",
    "apiKey": ""
  },
  "ltex-ls": {
    "path": "",
    "logLevel": "fine",
    "languageToolHttpServerUri": "",
    "languageToolOrgUsername": "",
    "languageToolOrgApiKey": ""
  },
  "java": {
    "path": "",
    "initialHeapSize": 64,
    "maximumHeapSize": 1024
  },
  "sentenceCacheSize": 10000,
  "completionEnabled": false,
  "diagnosticSeverity": "information",
  "checkFrequency": "edit",
  "clearDiagnosticsWhenClosingFile": true,
  "statusBarItem": true,
  "trace": {
    "server": "off"
  }
}

"LTeX Language Server" log file
Included in the problem description

"LTeX Language Client" log file
First, set the ltex.trace.server setting in your settings.json to "verbose". Then, reload the VS Code window and reproduce the bug. Go to ViewOutput and select LTeX Language Client in the drop-down list. Paste this log here (note: it will contain your checked document):

2023-10-03T14:12:45.513Z Info: Setting LTeX UI language to 'en'.
2023-10-03T14:12:45.513Z Info: Loading i18n messages...
2023-10-03T14:12:45.513Z Info: Loading default i18n messages...
2023-10-03T14:12:45.515Z Info: 
2023-10-03T14:12:45.515Z Info: ltex.ltex-ls.path not set.
2023-10-03T14:12:45.515Z Info: Searching for ltex-ls in '/home/attilio/.vscode-server/extensions/valentjn.vscode-ltex-13.1.0/lib'...
2023-10-03T14:12:45.515Z Info: ltex-ls found in '/home/attilio/.vscode-server/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0'.
2023-10-03T14:12:45.515Z Info: 
2023-10-03T14:12:45.515Z Info: Using ltex-ls from '/home/attilio/.vscode-server/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0'.
2023-10-03T14:12:45.515Z Info: Using Java bundled with ltex-ls as ltex.java.path is not set.
2023-10-03T14:12:45.517Z Info: Testing ltex-ls...
2023-10-03T14:12:45.517Z Info:   Command: "/home/attilio/.vscode-server/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0/bin/ltex-ls"
2023-10-03T14:12:45.517Z Info:   Arguments: ["--version"]
2023-10-03T14:12:45.517Z Info:   env['JAVA_HOME']: undefined
2023-10-03T14:12:45.517Z Info:   env['JAVA_OPTS']: "-Xms64m -Xmx512m"
2023-10-03T14:12:45.808Z Info: Test successful!
2023-10-03T14:12:45.818Z Info: 
2023-10-03T14:12:45.823Z Info: Starting ltex-ls...
2023-10-03T14:12:45.823Z Info:   Command: "/home/attilio/.vscode-server/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0/bin/ltex-ls"
2023-10-03T14:12:45.823Z Info:   Arguments: []
2023-10-03T14:12:45.823Z Info:   env['JAVA_HOME']: undefined
2023-10-03T14:12:45.823Z Info:   env['JAVA_OPTS']: "-Xms64m -Xmx512m"
2023-10-03T14:12:45.823Z Info: 
2023-10-03T14:14:23.875Z Info: Creating bug report...

Version information
List here the version information of the relevant software.

  • Operating system: Linux (linux), x64, 5.15.90.1-microsoft-standard-WSL2
  • VS Code: 1.82.3
  • vscode-ltex: 13.1.0
  • ltex-ls: 15.2.0
  • Java: 11.0.12

Additional context/information

@attiliocn attiliocn added 1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Oct 3, 2023
@mok33
Copy link

mok33 commented Nov 8, 2023

I also have the same issue unfortunately. Is there a way to tell ltex to ignore some line that he can't parse correctly ?

@attiliocn
Copy link
Author

I also have the same issue unfortunately. Is there a way to tell ltex to ignore some line that he can't parse correctly ?

I'm using the inline math environment as a workaround.

\documentclass[12pt]{report}
\begin{document}

Lorem ipsum$\Delta$ dolor sit amet, consectetur adipiscing elit. 

Lorem ipsum \begin{math}\Delta\end{math} dolor sit amet, consectetur adipiscing elit. 

\end{document}

image

@caioolivv
Copy link

Also having the same problem here. I can post the logs if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label)
Projects
None yet
Development

No branches or pull requests

3 participants