PillFall / languagetool.el

LanguageTool suggestions integrated within Emacs
GNU General Public License v3.0
98 stars 8 forks source link

error: (wrong-type-argument integer-or-marker-p nil) when applying or skipping a correction #14

Closed andreyorst closed 1 year ago

andreyorst commented 1 year ago

What version of Emacs are you running?

GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.17.4) of 2022-10-23

What version of LanguageTool are you running?

LanguageTool version 5.7 (2022-03-28 18:24:41 +0000, 35d0d40)

What version of this package are you running?

1.1.0

What is the current behaviour?

Error on applying a correction:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  languagetool-correction-apply(49 #<overlay in no buffer>)
  languagetool-correction-at-point()
  languagetool-correct-at-point()
  funcall-interactively(languagetool-correct-at-point)
  command-execute(languagetool-correct-at-point record)
  execute-extended-command(nil "languagetool-correct-at-point" nil)
  funcall-interactively(execute-extended-command nil "languagetool-correct-at-point" nil)
  command-execute(execute-extended-command)

What is you expect to happen?

No error

What do you do to get this bug?

1. Edit a file
2. Run a server via the command provided by a package
3. Enter server-mode
4. Try to correct something.

It happens irregularly, not sure what's causing it -- sometimes it works, sometimes it just doesn't.
PillFall commented 1 year ago

I was checking this, it happens in between server checks.

When you are quick enough to check before LanguageTool ends in Server mode, you check with the previous overlay attached, then LanguageTool ends and generates new ones, and you try to replace the previous one that already has been deleted.

PillFall commented 1 year ago

I will change the way server module send request by attaching the idle timer after a edit command. That way, this behavior should be partly corrected

PillFall commented 1 year ago

I was checking this, it happens in between server checks.

When you are quick enough to check before LanguageTool ends in Server mode, you check with the previous overlay attached, then LanguageTool ends and generates new ones, and you try to replace the previous one that already has been deleted.

This behaviour was not intended, as the correct command blocks server checking, preventing emacs to send a request to the server while the command is active. When I was testing, if the server is to slow to send a response (e.g. the document is too large) and you check while processing the request, the overlay you are attached to is the one that comes before the response. Then the response arrives, and all the overlays are deleted and recreated. Finally you select a replacement, but the overlay for replacement doesn't exist anymore, throwing the error.

To solve this, in addition to this:

I will change the way server module send request by attaching the idle timer after a edit command.

I will cancel the active request if a correction command is in progress.