Skip to content

Commit

Permalink
Remove superfluous spaces in diagnostic messages
Browse files Browse the repository at this point in the history
  • Loading branch information
valentjn committed Jan 15, 2021
1 parent c49d1ef commit 71e2a6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Add support for [GitLab Flavored Markdown](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md), especially inline math (e.g., ``$`E = mc^2`$``)
- Add support for Markdown tables as in [GitHub Flavored Markdown](https://github.github.com/gfm/#tables-extension-)
- Enable `Add to dictionary` quick fix for Slovak rule IDs `MUZSKY_ROD_NEZIV_A`, `ZENSKY_ROD_A`, and `STREDNY_ROD_A` (fixes [vscode-ltex#221](https://github.com/valentjn/vscode-ltex/issues/221))
- Remove superfluous spaces in messages of diagnostics
- Use Flexmark's YAML Front Matter extension to ignore YAML front matter in Markdown instead of own handling
- Print Flexmark AST of Markdown documents to log when [`ltex.ltex-ls.logLevel`](https://valentjn.github.io/vscode-ltex/docs/settings.html#ltexltex-lsloglevel) is `"finest"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.bsplines.ltexls.parsing.AnnotatedTextFragment;
import org.bsplines.ltexls.server.LtexTextDocumentItem;
import org.bsplines.ltexls.tools.Tools;
Expand All @@ -19,6 +20,8 @@
import org.languagetool.rules.RuleMatch;

public class LanguageToolRuleMatch {
private static final Pattern twoOrMoreSpacesPattern = Pattern.compile("[ \n]{2,}");

private @MonotonicNonNull String ruleId;
private @MonotonicNonNull String sentence;
private int fromPos;
Expand Down Expand Up @@ -47,6 +50,8 @@ public LanguageToolRuleMatch(@Nullable String ruleId, @Nullable String sentence,
String unknownWord = annotatedTextFragment.getSubstringOfPlainText(fromPos, toPos);
this.message = "'" + unknownWord + "': " + this.message;
}

this.message = twoOrMoreSpacesPattern.matcher(message).replaceAll(" ").trim();
}

public @Nullable String getRuleId() {
Expand Down

0 comments on commit 71e2a6c

Please sign in to comment.