Skip to content

Conversation

@benthamite
Copy link

Description

This PR fixes an issue where the error (wrong-type-argument sequencep <number>) is triggered when LanguageTool returns an error response. The problem occurs because the current implementation calls the error callback but then continues execution, attempting to apply mapcar to a non-sequence value.

Changes

  • Restructured the flycheck-languagetool--read-results function to use an if-else pattern
  • Ensured that after reporting an error via the callback, the function terminates without further processing
  • Moved the error handling to properly encapsulate the entire callback execution

@jcs090218
Copy link
Member

The error function call should stop the execution. 🤔

@benthamite
Copy link
Author

Mmh, I'm not sure what’s going on. The errors disappeared after what I believe was this change, but I also made other changes. Another candidate is

-    (with-current-buffer source-buffer
-      (funcall
-       callback 'finished
-       (flycheck-increment-error-columns
-        (mapcar
-         (lambda (x)
-           (apply #'flycheck-error-new-at `(,@x :checker languagetool)))
-         (condition-case err
-             (flycheck-languagetool--check-all results)
-           (error (funcall callback 'errored (error-message-string err))))))))))
+    ;; Check if the source buffer is still live before processing results.
+    (when (buffer-live-p source-buffer)
+      (with-current-buffer source-buffer
+        (funcall
+         callback 'finished
+         (flycheck-increment-error-columns
+          (mapcar
+           (lambda (x)
+             (apply #'flycheck-error-new-at `(,@x :checker languagetool)))
+           (condition-case err
+               (flycheck-languagetool--check-all results)

Do you think this might be the right way to patch it?

The backtrace is:

Debugger entered--Lisp error: (error "Selecting deleted buffer")
  flycheck-languagetool--read-results(nil #<killed buffer> #f(compiled-function (&rest args) #<bytecode 0x3b3e1e5358fd5da>))
  url-http-activate-callback()
  url-http-content-length-after-change-function(4194444 4829059 634615)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants