Bug 160226 - LibreOffice Math: Clicking on visual elements (i.e. fraction) completely destroys your formula structure
Summary: LibreOffice Math: Clicking on visual elements (i.e. fraction) completely dest...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
Depends on:
Blocks: Visual-Mode-of-Formula-Editor
  Show dependency treegraph
 
Reported: 2024-03-16 06:30 UTC by george
Modified: 2024-03-25 13:03 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Using Libre Math's visual elements destroys formula structure (270.51 KB, image/jpeg)
2024-03-16 06:48 UTC, george
Details

Note You need to log in before you can comment on or make changes to this bug.
Description george 2024-03-16 06:30:21 UTC
Description:
While typing a formula, if you click on a visual element i.e. a fraction, the fraction is inserted in the formula in the wrong place instead of the cursor's current position.

Steps to Reproduce:
1. start typing a formula
2. click on a visual element (i.e. a fraction)


Actual Results:
3. The visual element you clicked is inserted at the beginning of the formula an not at the current cursor's position

Expected Results:
The visual element you clicked should be inserted at the current cursor's position (as it was happening prior to 24.x.x version)


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 24.2.1.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 16; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: el-GR (en_US.UTF-8); UI: en-US
Ubuntu package version: 4:24.2.1~rc2-0ubuntu0.22.04.1~lo1
Calc: threaded
Comment 1 george 2024-03-16 06:48:15 UTC
Created attachment 193137 [details]
Using Libre Math's visual elements destroys formula structure
Comment 2 V Stuart Foote 2024-03-16 12:05:56 UTC
Confirmed. The element insertion does not track the Visual mode cursor, and resulting node is misplaced. 

Version: 24.2.1.2 (X86_64) / LibreOffice Community
Build ID: db4def46b0453cc22e2d0305797cf981b68ef5ac
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded

You can revert to non-visual command input window. Done from Tools -> Options -> LibreOffice Math -> Settings panel. Uncheck the now default 'Enable Visual Editing'
Comment 3 george 2024-03-16 12:20:13 UTC
(In reply to V Stuart Foote from comment #2)
> Confirmed. The element insertion does not track the Visual mode cursor, and
> resulting node is misplaced. 
> 
> Version: 24.2.1.2 (X86_64) / LibreOffice Community
> Build ID: db4def46b0453cc22e2d0305797cf981b68ef5ac
> CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Vulkan; VCL:
> win
> Locale: en-US (en_US); UI: en-US
> Calc: CL threaded
> 
> You can revert to non-visual command input window. Done from Tools ->
> Options -> LibreOffice Math -> Settings panel. Uncheck the now default
> 'Enable Visual Editing'

thank you for this workaround.

I now realize that using this "visual mode" I can type inside the "visual" window, which works fine. But if I use the "latex" editor and then click on visual element then it is misplaced.
Comment 4 Stéphane Guillou (stragu) 2024-03-17 10:41:53 UTC
No repro in 7.6 with experimental mode turned on:

Version: 7.6.5.2 (X86_64) / LibreOffice Community
Build ID: 38d5f62f85355c192ef5f1dd47c5c0c0c6d6598b
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

Reproduced in 24.2.1:

Version: 24.2.1.1 (X86_64) / LibreOffice Community
Build ID: 359ef544e625d2ffbfced462ab37bd593ca85fa7
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

So it's a regression.
Comment 5 Stéphane Guillou (stragu) 2024-03-18 02:11:53 UTC
As I understand it, this was done on purpose with:

commit ee187f6ed7873f3ebc1f845a4384a84713be1e9c
author	Khaled Hosny 	Tue Sep 05 20:24:13 2023 +0300
committer	خالد حسني 	Tue Sep 05 20:28:34 2023 +0200
starmath: Always insert using SmCursor when inline editing is enabled
Choosing which code path based on which widget has focus is not a very
good idea, and leads to unreliable UI tests as each code path inserts
the text slightly differently (one code path inserts plain text then
parses the whole equation again, while the other parses the new text
then inserts the parsed node directly).
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156578

Khaled, any chance this could be handled better? I assume more users than us 3 will perceive this as a bug. Jumping between visual and syntax editing with the help of the Elements sidebar is to be expected, in my opinion.
Comment 6 Heiko Tietze 2024-03-18 08:32:40 UTC
Seems the cursor does not follow textual input. If you enter content in the document the elements are inserted at the cursor position. => bug
Comment 7 ⁨خالد حسني⁩ 2024-03-19 20:45:51 UTC
At this point I think we should flip the default back to disable visual editing. It seems to be more trouble than it is worth it without someone invested in fixing these issues. I don’t have a working LO build setup, though, so someone else has to do it.
Comment 8 Stéphane Guillou (stragu) 2024-03-20 02:33:00 UTC
Thanks, Khaled.
Xisco, what do you think?

- 2d47c824cd31294899fa24989b3d7bd4f98dcdee: Visual mode made default + option to turn it off, in which Khaled did note: "If it turns to be a disaster, we can flip the option and disable it by default."
- ee187f6ed7873f3ebc1f845a4384a84713be1e9c: Always insert using SmCursor.

Instead of reverting everything, we can default to Visual mode off but keep it out of experimental, and this report can stay open.
Comment 9 V Stuart Foote 2024-03-20 11:40:32 UTC
(In reply to Stéphane Guillou (stragu) from comment #8)

> ...
> Instead of reverting everything, we can default to Visual mode off but keep
> it out of experimental, and this report can stay open.

+1, reasonable to keep it graduated but not as default mode (using the new checkbox on Tools -> Options -> LO Math -> Settings). 

And Visual mode still needs a lot of documentation effort as for bug 159989 which until then likely will result in more avoidable issues being reported.