Bug 157258 - "Always autocorrect to" deletes the word instead of replacing (affects extensions like Grammalecte, LanguageTool, Antidote)
Summary: "Always autocorrect to" deletes the word instead of replacing (affects extens...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.0.0 alpha0+
Hardware: All All
: high normal
Assignee: Caolán McNamara
URL: https://ask.libreoffice.org/t/fonctio...
Whiteboard: target:24.8.0 target:24.2.3 target:7.6.7
Keywords: bibisected, bisected, regression
: 154739 (view as bug list)
Depends on:
Blocks: Context-Menu AutoCorrect-Complete
  Show dependency treegraph
 
Reported: 2023-09-15 11:23 UTC by Constant
Modified: 2024-04-02 08:31 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Constant 2023-09-15 11:23:27 UTC
Description:
The "Always AutoCorrect to" function normally allows you to correct a word containing an error into another manually selected word, an erroneous word which will then be corrected each time by this word selected the first time. To do this, this last function is linked to the "AutoCorrect" function (which, obviously, must be activated with the "While typing" option).

However, for several months, as soon as I use the "Always AutoCorrect to" function to replace an incorrect word and I choose a word to replace it, the incorrect word simply disappears. Without being replaced. And when, later, I make the mistake that I wanted to correct automatically, LibreOffice corrects it for me by, once again, a deletion. Instead of the correct word that would normally be substituted.

I just noticed that when I uninstall the "Grammalecte" extension (French grammar extension absolutely necessary for all the French community), there are no more problems. It is therefore this extension which poses a problem. However, it did not pose a problem in previous versions of LibreOffice: the bug therefore comes from LO.

Steps to Reproduce:
1. Download, install and set up the Grammalecte extension
2. Write a word containing an error which will then be highlighted in red
3. Right click on this word and place the mouse on “Always AutoCorrect to”
4. Left-click on a word that would normally replace it (spoiler: it doesn't replace it but just make it dissapear)

Actual Results:
As soon as I use the "Always AutoCorrect to" function to replace an incorrect word and I choose a word to replace it, the incorrect word simply disappears. Without being replaced. And when, later, I make the mistake that I wanted to correct automatically, LibreOffice corrects it for me by, once again, a deletion. Instead of the correct word that would normally be substituted.

Expected Results:
A compatibility between "Always AutoCorrect to" function and Grammalecte extension: those both tools have to work well together.

The expected results would be, while having Grammalecte extension, being able to use "Always AutoCorrect to" function normally: effectively, normally, this function allows you to correct a word containing an error into another manually selected word, an erroneous word which will then be corrected each time by this word selected the first time. To do this, this last function is linked to the "AutoCorrect" function (which, obviously, must be activated with the "While typing" option).


Reproducible: Always


User Profile Reset: Yes

Additional Info:
/
Comment 1 Buovjaga 2023-09-28 10:26:02 UTC
Might be worth it to report also to Grammalecte: http://grammalecte.net:8080/ticket
Comment 2 Constant 2023-09-28 16:20:39 UTC
(In reply to Buovjaga from comment #1)
> Might be worth it to report also to Grammalecte:
> http://grammalecte.net:8080/ticket

Thank you for the suggestion, I will do it so that it can be seen by one of these two entities. However, there are no issues with Autocorrect and Grammalect on the latest versions of LibreOffice, so this is due to the latest LibreOffice updates and not Grammalect.
Comment 3 Stéphane Guillou (stragu) 2023-10-03 12:12:16 UTC
Reproduced in 7.4.7.2 and 7.6:

Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

- AutoCorrect rules in the table always work as expected
- Without Grammalecte 2.1.2 installed (or with it disabled), "Right-click > Always AutoCorrect to" works as expected
- With Grammalecte 2.1.2 installed, "Right-click > Always AutoCorrect to" removes the word
- I don't have to use French UI, locale or paragraph/document language to test.
- Nothing in the console, even for a debug build.

Issue reported on Ask.LO: https://ask.libreoffice.org/t/fonctions-toujours-corriger-automatiquement-en-et-autocorrection-buggees/95529/3
And on the FR mailing list (thanks Sophie!): https://listarchives.libreoffice.org/fr/users/2022/msg00597.html

Not reproduced in:

Version: 7.3.7.2 / LibreOffice Community
Build ID: e114eadc50a9ff8d8c8a0567d6da8f454beeb84f
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Tried to bibisect it with the linux-64-7.4 repository and spanish-dictionaries for spellcheck, but there's a crashing range

- oldest: works as expected
- since 90bf995886394ca0da189b5b61a35659ada696e7 (source afa35742a4633db31b6d6c72cf45741506e9edfb), "Always autocorrect to" crashes
- since d541202a5d8388c8fa5395eaed252ffb8a7af360 (source 7e4ddea574b18aeed678526cac42f45613b4ae20), crash is fixed but bug is reproduced (word removed instead of being replaced)

So we've got the following range to work from:

https://git.libreoffice.org/core/+log/afa35742a4633db31b6d6c72cf45741506e9edfb..7e4ddea574b18aeed678526cac42f45613b4ae20

... which is 899 commits long.

I don't get any hits with:

git log afa35742a4633db31b6d6c72cf45741506e9edfb..7e4ddea574b18aeed678526cac42f45613b4ae20 --grep="autocorrect"

Caolán, I know it's a long shot, but just because you tdf#146342 fix is the last one of the range, and spelling-related, any idea what might be going wrong here?
Comment 4 Stéphane Guillou (stragu) 2023-12-15 09:47:08 UTC
*** Bug 154739 has been marked as a duplicate of this bug. ***
Comment 5 Stéphane Guillou (stragu) 2023-12-15 09:51:05 UTC
Upping the priority as it is a regression that affects several extensions.

Please see Jasmin's pointer in bug 154739 comment 14:

(In reply to Jasmin Lapalme from bug 154739 comment #14)
> We think that the problem is within LibreOffice. The sample code is pretty
> simple and involves no logic at all. We simply register a
> `com.sun.star.ui.XContextMenuInterceptor` and return CONTINUE_MODIFIED
> without any modification to the context menu. 
> [...]
> If the problem is indeed in LibreOffice, every extension that registers an
> interceptor has the potential to break the autocorrect.
Comment 6 Stéphane Guillou (stragu) 2023-12-21 16:46:30 UTC
Not sure what went wrong with my comment 3 bibisect, but it actually started with the first one from the range:

commit afa35742a4633db31b6d6c72cf45741506e9edfb
author	Caolán McNamara 	Sat Dec 11 21:09:39 2021 +0000
committer	Caolán McNamara 	Sun Dec 12 13:35:00 2021 +0100
prefer more css::awt::XPopupMenu api
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126692

...which makes sense because it's a context menu change.

Caolán, can you please have a look?
Comment 7 Caolán McNamara 2024-03-30 20:33:33 UTC
I see now what this weirdness happens from an apparently innocuous change
Comment 8 Commit Notification 2024-03-31 10:02:07 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7f7a7cf0eca793a9efb8456f96ccfece07f6f9d9

Resolves: tdf#157258 "Always autocorrect to" deletes the word

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Caolán McNamara 2024-03-31 10:02:45 UTC
fixed in trunk, backport to 24-2 in gerrit
Comment 10 Commit Notification 2024-03-31 18:50:13 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/161bcfa1c8687570acde0947b0350c70e7021d85

Resolves: tdf#157258 "Always autocorrect to" deletes the word

It will be available in 24.2.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2024-04-02 01:40:43 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/19b6d9c470e1b6b9c8b555aaee119425c8837852

Resolves: tdf#157258 "Always autocorrect to" deletes the word

It will be available in 7.6.7.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Stéphane Guillou (stragu) 2024-04-02 08:31:28 UTC
Thanks, Caolán! Always fun to step on a 14 year old trap.

I verified the fix with:

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 069bf61cea5e3aea07ffd5a1bb9f55324651cb35
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: CL threaded

... and LanguageTool 5.9.1.
(I had to test with LT because I could not reproduce the issue with Grammalecte since the 24.2 C++20 baseline bump, 1eef07805021b7ca26a1a8894809b6d995747ba1.)