Skip to content

Commit

Permalink
Fix wrong error parsing in Console Mode
Browse files Browse the repository at this point in the history
Console mode was parsing the arguments from the debug buffer, instead of
the ones where the check command was triggered
  • Loading branch information
PillFall committed Mar 25, 2023
1 parent c3f76d9 commit 54acbc3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions languagetool-console.el
Expand Up @@ -138,19 +138,20 @@ for this package to work."
(push (list "--disable" rules) arguments )))
(flatten-tree (reverse arguments))))

(defun languagetool-console-write-debug-info (text)
(defun languagetool-console-write-debug-info (parsed-arguments text)
"Write debug info in `languagetool-console-output-buffer-name'.
The argument TEXT is the region passed to LanguageTool for
checking."
PARSED-ARGUMENTS is a list with all the arguments that are passed
to LanguageTool and Java.
TEXT is the region passed to LanguageTool for checking."
(insert
(propertize " ----- LanguageTool Command:" 'face 'font-lock-warning-face)
"\n\n"
(string-join
(append
(list languagetool-java-bin)
(languagetool-java-parse-arguments)
(languagetool-console-parse-arguments))
parsed-arguments)
" ")
"\n\n\n\n"
(propertize " ----- LanguageTool Text:" 'face 'font-lock-warning-face)
Expand All @@ -176,19 +177,21 @@ The region is delimited by BEGIN and END."
(let ((status 0)
(buffer (get-buffer-create languagetool-console-output-buffer-name))
(text (buffer-substring-no-properties begin end))
(json-parsed nil))
(json-parsed nil)
(parsed-arguments
(append
(languagetool-java-parse-arguments)
(languagetool-console-parse-arguments))))
(with-current-buffer buffer
(erase-buffer)
(languagetool-console-write-debug-info text))
(languagetool-console-write-debug-info parsed-arguments text))
(setq status
(apply #'call-process-region begin end
languagetool-java-bin
nil
languagetool-console-output-buffer-name
nil
(append
(languagetool-java-parse-arguments)
(languagetool-console-parse-arguments))))
parsed-arguments))
(when (/= status 0)
(error "LanguageTool returned with status %d" status))
(with-current-buffer buffer
Expand Down

0 comments on commit 54acbc3

Please sign in to comment.