Bug 465277 - Cantor doesn't handle multi-command cells very well
Summary: Cantor doesn't handle multi-command cells very well
Status: RESOLVED FIXED
Alias: None
Product: cantor
Classification: Applications
Component: maxima-backend (other bugs)
Version First Reported In: 22.12.1
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: Cantor Bugs
URL:
Keywords:
: 465278 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-02-04 16:43 UTC by Jack Hill
Modified: 2023-03-29 06:29 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 23.03
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Hill 2023-02-04 16:43:18 UTC
SUMMARY
Multiple commands in a cell don't always print their output.


STEPS TO REPRODUCE
1. Enter the following into a cell:

a: 1;
b: 2;
c: 3;

2. Run the cell multiple times

OBSERVED RESULT
A few things can happen:
1. Cantor hangs (seemingly) forever
2. The variable explorer thinks there's a variable with Name "3" and Value "23"
3. The only output is "1"
4. The variable and output are correct, but the syntax highlighting doesn't think a, b, c are variables
5. If the entry had been copied & pasted, then Cantor may crash (haven't been able to reproduce this without copy&paste)

EXPECTED RESULT
The output should be:
1
2
3

The variables "a", "b", "c", should be listed in the variable explorer with values "1", "2", "3" respectively.

The variables "a", "b", "c" should be highlighted as variables in all cells.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20230201
KDE Plasma Version: 5.26.5
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8
Kernel Version: 6.1.8-1-default (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
Comment 1 Alexander Semke 2023-02-07 07:49:42 UTC
(In reply to Jack Hill from comment #0)
> SUMMARY
> Multiple commands in a cell don't always print their output.
> [...]
Which version of maxima do you have installed? Which output do you get if you just start maxima in the terminal?
Comment 2 Jack Hill 2023-02-07 14:54:02 UTC
I've got maxima 5.46.0

This is the output:
jack@localhost:~> maxima
Maxima 5.46.0 https://maxima.sourceforge.io
using Lisp SBCL 2.3.1-1.1-suse
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) a: 1; b: 2; c: 3;
(%o1)                                  1
(%o2)                                  2
(%o3)                                  3
Comment 3 Alexander Semke 2023-02-09 07:38:40 UTC
The problem here is Maxima is generating multiple outputs, one for each result, and we react on the first output only since the user entry is evaluated as one "expression" and sent to Maxima in one single step. So, we expect one single response which is not the case with Maxima apparently. I'll check how to fix it. Thanks for reporting this issue!
Comment 4 Alexander Semke 2023-03-26 17:21:55 UTC
Git commit 5484889e50b28b95ce468a1fbeb1854e87da6dde by Alexander Semke.
Committed on 26/03/2023 at 17:21.
Pushed by asemke into branch 'master'.

[maxima] always trim the command string and remove line breaks and not only for plot commands so we get one single response in stdout from Maxima
instead of multiple outputs that we only partially handle. This addresses multiple issues with multi-line commands with $ and ; endings.
FIXED-IN: 23.03

M  +1    -1    src/backends/maxima/maximasession.cpp
M  +42   -2    src/backends/maxima/testmaxima.cpp
M  +6    -2    src/backends/maxima/testmaxima.h

https://invent.kde.org/education/cantor/commit/5484889e50b28b95ce468a1fbeb1854e87da6dde
Comment 5 Alexander Semke 2023-03-26 17:22:20 UTC
*** Bug 465278 has been marked as a duplicate of this bug. ***
Comment 6 Alexander Semke 2023-03-29 06:29:33 UTC
Git commit 872008a2ca0a983adb49141dd7e866f549658176 by Alexander Semke.
Committed on 29/03/2023 at 06:26.
Pushed by asemke into branch 'release/23.04'.

Squash commit of multiple fixes that need to go into 23.04.

[tests] make initTestCase() in the base class a slot so it's properly found by QtTest
and skip two tests in Maxima and Python that are failing on CI right now,
will be activated once the underlying issue is fixed.

[tests] skip testInterrupt for python.

[lua] refactored and fixed the parsing of LuaJIT's output.

The current implementation doesn't work at all, the output of LuaJIT doesn't fit to the parsing logic (anymore) that was implemented initially.
The refactored code works and handles also multi-line commands where the tests were deactivated earlier for.
More testing and more investment is still probably required to cover more code syntax in Lua/LuaJIT.
This commit makes the lua backend in Cantor working now first, more improvements will come later.
Related: bug 461135
FIXED-IN: 23.03

[maxima] always trim the command string and remove line breaks and not only for plot commands so we get one single response in stdout from Maxima
instead of multiple outputs that we only partially handle. This addresses multiple issues with multi-line commands with $ and ; endings.
FIXED-IN: 23.03

Added changes that were forgotten in the previous two commits.

When using cantor in labplot, connectToShell() is called after widget() inDocumentationPanelWidget.
We need to add one more connect in connectToShell() so the actions are also working in labplot.

[octave] evaluate the option "integrate plots" on every expression execution and not only during the login
so the user doesn't need to restart Cantor if the options is being changed.

Previously, this option was evaluate at the very beginning and send to Octave via  set (0, "defaultfigurevisible","off")
during the login. In this commit we switch to figure('visible','on') and figure('visible','off') that are prepended to every expression
containing plot commands.

Also, we set the recommended version of Octave to 7.2 which is available for one year already.

[octave] restored the slot OctaveSession::processError() that was deleted in the previous commit.

M  +1    -1    src/backends/lua/luabackend.cpp
M  +17   -4    src/backends/lua/luaexpression.cpp
M  +31   -107  src/backends/lua/luasession.cpp
M  +10   -16   src/backends/lua/luasession.h
M  +64   -29   src/backends/lua/testlua.cpp
M  +2    -6    src/backends/lua/testlua.h
M  +10   -10   src/backends/maxima/maximaexpression.cpp
M  +1    -1    src/backends/maxima/maximasession.cpp
M  +57   -16   src/backends/maxima/testmaxima.cpp
M  +6    -2    src/backends/maxima/testmaxima.h
M  +1    -1    src/backends/octave/octavebackend.cpp
M  +13   -4    src/backends/octave/octaveexpression.cpp
M  +45   -65   src/backends/octave/octavesession.cpp
M  +5    -8    src/backends/octave/octavesession.h
M  +4    -4    src/backends/python/testpython.cpp
M  +3    -1    src/lib/test/backendtest.h
M  +6    -1    src/panelplugins/documentationpanel/documentationpanelplugin.cpp

https://invent.kde.org/education/cantor/commit/872008a2ca0a983adb49141dd7e866f549658176