Bug 144547 - Editing a multi-line formula, changing a cell reference on another than the first line with drag & drop it is repeated forever in the formula's first line
Summary: Editing a multi-line formula, changing a cell reference on another than the f...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:7.6.0 target:7.5.4
Keywords: bibisected, bisected
Depends on:
Blocks: Calc-Formula-Bar
  Show dependency treegraph
 
Reported: 2021-09-16 13:34 UTC by elias estatistics
Modified: 2023-05-07 18:51 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
bug_repeated_Cell_Name_in_formula (14.00 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-09-16 13:34 UTC, elias estatistics
Details
bug_repeated_Cell_Name_in_formula - tidier (12.57 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-09-16 13:39 UTC, elias estatistics
Details

Note You need to log in before you can comment on or make changes to this bug.
Description elias estatistics 2021-09-16 13:34:58 UTC
Created attachment 175073 [details]
bug_repeated_Cell_Name_in_formula

1) I have a formula
2) I try to change with drug & drop using mouse the cell reference. 
3) Cell name is repeared in formula as many times as you move it around. 

Attachment: 

a) In cell C6 press "F2" in order to access cell content 
b) Then, in Cell AA2, a "Red" Cell appears.
c) Try to move this "Red" cell to a new cell
d) Cell name is repeared in formula as many times as you move it around.
Comment 1 elias estatistics 2021-09-16 13:39:25 UTC
Created attachment 175074 [details]
bug_repeated_Cell_Name_in_formula - tidier

a more tidier example 

Cell a6, press F2, and then move C2 cell to new locations.
Comment 2 raal 2021-09-17 13:56:06 UTC
This seems to have begun at the below commit.
Adding Cc: to 	Eike Rathke ; Could you possibly take a look at this one?
Thanks
 60af280fe15025d08d5f1ceecdb25d243c68f1b2 is the first bad commit
commit 60af280fe15025d08d5f1ceecdb25d243c68f1b2
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Wed Jul 28 19:07:59 2021 +0200

    source 516318113f0bd2b3c658aba9b285165e63a280e2

https://git.libreoffice.org/core/+/516318113f0bd2b3c658aba9b285165e63a280e2
   Resolves: tdf#76310 Preserve whitespace TAB, CR, LF in formula expressions
Comment 3 BogdanB 2023-04-23 18:50:51 UTC
Still repro
Version: 7.5.2.1 (X86_64) / LibreOffice Community
Build ID: e8bf3b441b8370f8440b0339fd9490765a8d57ca
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 4 ady 2023-04-23 20:46:30 UTC Comment hidden (no-value)
Comment 5 ady 2023-04-23 20:53:23 UTC
Hmm... OTOH, the formula includes #REF! errors. Why anyone would care about solving something with a broken formula, before actually solving the formula itself first?

Is this repeatable with a non-broken formula?
Comment 6 Eike Rathke 2023-04-24 16:54:33 UTC Comment hidden (no-value)
Comment 7 Eike Rathke 2023-04-24 17:02:52 UTC
It's not even a regression because previously editing multi-line formulas wasn't possible at all.

What happens seems to be that something blindly appends the new reference to the end of the first line instead of modifying the correct string position.

(In reply to ady from comment #5)
> Hmm... OTOH, the formula includes #REF! errors. Why anyone would care about
> solving something with a broken formula, before actually solving the formula
> itself first?
Unrelated.

> Is this repeatable with a non-broken formula?
Yes. Just enter

=B1
+B2

as multi-line formula in A1, then F2 to edit and drag&drop cell B2.
Comment 8 ady 2023-04-25 00:49:46 UTC
(In reply to Eike Rathke from comment #7)
> Yes. Just enter
> 
> =B1
> +B2
> 
> as multi-line formula in A1, then F2 to edit and drag&drop cell B2.

That example also shows that cell B2 is marked (so it can be dragged), but B1 is not.
Comment 9 Commit Notification 2023-04-25 18:35:36 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5f6d27711a297d1851dc6bc713fd16c44014cf5c

Resolves: tdf#144547 ScRangeFindList: handle references in multi-line formula

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 10 Eike Rathke 2023-04-25 18:37:52 UTC
Pending review https://gerrit.libreoffice.org/c/core/+/151010 for 7-5
Comment 11 ady 2023-04-27 10:26:28 UTC
(In reply to Commit Notification from comment #9)
> It will be available in 7.6.0.

Works as expected now in 7.6.alpha.
Comment 12 Commit Notification 2023-05-07 18:51:08 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/f6a783af88b571ff1f3df9bda31eb0aac66a2c5f

Resolves: tdf#144547 ScRangeFindList: handle references in multi-line formula

It will be available in 7.5.4.

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.