Bug 155407 - Incorrect autocorrection of double dashes in a specific situation
Summary: Incorrect autocorrection of double dashes in a specific situation
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
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:7.6.0 target:7.5.5
Keywords:
: 94911 (view as bug list)
Depends on:
Blocks: AutoCorrect-Complete
  Show dependency treegraph
 
Reported: 2023-05-19 12:24 UTC by Mike Kaganski
Modified: 2023-07-12 04:25 UTC (History)
2 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 Mike Kaganski 2023-05-19 12:24:09 UTC
In a Writer text, type:

Something
Foo - 111--222 

(after the last "2", type a space)

The text will get replaced into

Something
Foo – 111–222 

so the first dash turns into an en-dash, and the two dashes between 111 and 222 turn into another en-dash. So far so good, this is the expected and wanted behavior.

Now delete everything, and type

Something
Foo -- 111--222 

(after the last "2", type a space)

The text will get replaced into

Something
Foo – 111-–22 

so the first two dashes turn into an en-dash (as expected), but the two dashes between numbers get replaced incorrectly: the first dash is kept, and the autocorrection replaced the text "-2" with an en dash.

This is wrong character indices used in SvxAutoCorrect::FnChgToEnEmDash, that don't take into account that the document text may change length as the result of the first replacement.
Comment 1 Commit Notification 2023-05-20 11:31:35 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/075ecc1c31199d0fd0f930cf1b803b04a3b17ce8

tdf#155407: fix the second replacement in FnChgToEnEmDash

It will be available in 7.6.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 2 Commit Notification 2023-05-22 11:03:18 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/9eae9409a739c21ea27a480f55b434df8e613acd

tdf#155407: fix the second replacement in FnChgToEnEmDash

It will be available in 7.5.5.

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 3 Stéphane Guillou (stragu) 2023-06-27 05:47:54 UTC
*** Bug 94911 has been marked as a duplicate of this bug. ***
Comment 4 Stéphane Guillou (stragu) 2023-07-01 19:02:39 UTC
Started in 7.4 but inconsistent results (why...?) made it not worth pinpointing.

Verified in:

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

Thanks Mike, it also fixed ~8yo bug 94911.