From 59c6008f85f65e6de2f3a5946a495cdc2de28e23 Mon Sep 17 00:00:00 2001 From: Julian Valentin Date: Wed, 25 Sep 2019 16:20:11 +0200 Subject: [PATCH] Ignore all {}/[] arguments after \begin{env} --- .../latex/LatexAnnotatedTextBuilder.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/bsplines/languagetool_languageserver/latex/LatexAnnotatedTextBuilder.java b/src/main/java/org/bsplines/languagetool_languageserver/latex/LatexAnnotatedTextBuilder.java index 35ec4f37..130522e2 100644 --- a/src/main/java/org/bsplines/languagetool_languageserver/latex/LatexAnnotatedTextBuilder.java +++ b/src/main/java/org/bsplines/languagetool_languageserver/latex/LatexAnnotatedTextBuilder.java @@ -430,10 +430,26 @@ public LatexAnnotatedTextBuilder addCode(String text) throws InterruptedExceptio preserveDummyLast = true; addMarkup(argument, interpretAs); - if (environment.equals("tabular")) { - String environmentArgument = LatexCommandSignature.matchArgumentFromPosition( - text, pos, LatexCommandSignature.ArgumentType.BRACE); - addMarkup(environmentArgument); + if (command.equals("\\begin")) { + while (pos < text.length()) { + if (Thread.currentThread().isInterrupted()) throw new InterruptedException(); + + String environmentArgument = LatexCommandSignature.matchArgumentFromPosition( + text, pos, LatexCommandSignature.ArgumentType.BRACE); + + if (!environmentArgument.isEmpty()) { + addMarkup(environmentArgument); + } else { + environmentArgument = LatexCommandSignature.matchArgumentFromPosition( + text, pos, LatexCommandSignature.ArgumentType.BRACKET); + + if (!environmentArgument.isEmpty()) { + addMarkup(environmentArgument); + } else { + break; + } + } + } } } else if (command.equals("\\$") || command.equals("\\%") || command.equals("\\&")) { addMarkup(command, command.substring(1));