Fix: Multiline input broken in Julia executable folds#15
Open
Parth-Garg2629 wants to merge 1 commit intomgubi:mainfrom
Open
Fix: Multiline input broken in Julia executable folds#15Parth-Garg2629 wants to merge 1 commit intomgubi:mainfrom
Parth-Garg2629 wants to merge 1 commit intomgubi:mainfrom
Conversation
…ble folds
Calling (plugin-input-converters julia) — even with no conversion rules —
registers 'julia' into the plugin-input-converters% logic group. The predicate
plugin-supports-math-input-ref checks exactly this group:
(tm-define (plugin-supports-math-input-ref key)
(lazy-input-converter-force key)
(logic-in? key plugin-input-converters%)) ; defined in plugin-convert.scm
When this returns #t, plugin-preprocess (plugin-eval.scm) pipes the input tree
through plugin-math-input which flattens the document tree into a single math
expression, stripping all newline characters. This caused every line of a
multiline Julia cell inside an executable fold (Insert -> Fold -> Executable)
to be concatenated into one line, silently breaking multi-statement blocks.
Julia already has a custom serializer (julia-serialize) that calls
texmacs->code with SourceCode style and appends the <EOF> sentinel correctly.
Math-input pre-processing is therefore not needed and keeping it disabled is
the correct behaviour.
Fix: remove the bare (when (supports-julia?) (plugin-input-converters julia))
block entirely, with a detailed explanation comment in its place.
Fixes: mgubi#12
Author
|
@mgubi @hammerfunctor could u please review my PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Multiline input broken in Julia executable folds
**Closes #14 **
🐛 Problem
Multiline Julia code inside executable folds (
Insert → Fold → Executable) was silently broken — all lines were concatenated into a single line before being sent to the Julia process, causing multi-statement blocks to fail.Example of broken behaviour:
A fold containing:
Was being serialised and sent to Julia as the single line:
which raises a parse error or produces wrong results.
🔍 Root Cause
The two lines at the bottom of
progs/init-julia.scm:were the culprit. Even when called with no conversion rules, the macro
plugin-input-convertersregisters the plugin name into theplugin-input-converters%logic group (inplugin-convert.scm):The predicate
plugin-supports-math-input-refchecks exactly this group:(tm-define (plugin-supports-math-input-ref key) (lazy-input-converter-force key) (logic-in? key plugin-input-converters%)) ;; ← returns #t after the call aboveOnce
plugin-supports-math-input-refreturns#tfor"julia",plugin-preprocess(inplugin-eval.scm) routes the entire input tree throughplugin-math-input:plugin-math-inputflattens the TeXmacs document tree into a single math expression, stripping every newline in the process. This is what destroyed the multiline structure of Julia code cells.✅ Fix
Remove the
(when (supports-julia?) (plugin-input-converters julia))block entirely.Julia already registers a custom serializer (
julia-serialize) via(:serializer ,julia-serialize)inplugin-configure. That serializer callstexmacs->codewith"SourceCode"style and appends the<EOF>sentinel correctly — it handles the full document tree, preserving newlines. Math-input pre-processing is therefore not needed and must be kept disabled.A detailed explanatory comment has been added in place of the removed code to prevent future regressions.
📂 Files Changed
progs/init-julia.scm(when (supports-julia?) (plugin-input-converters julia)); added a detailed explanatory comment🧪 How to Test
Install the plugin and open TeXmacs / Mogan.
Go to
Insert → Fold → Executable → Julia.Enter a multiline Julia block, e.g.:
Execute the fold.
Before this fix: All lines are collapsed into one; Julia raises a parse or runtime error.
After this fix: Each line is preserved; Julia returns a reproducible random float (e.g.,
0.6293451231426089).📎 References
TeXmacs/progs/utils/plugins/plugin-convert.scm— definesplugin-input-convertersmacro andplugin-supports-math-input-refTeXmacs/progs/utils/plugins/plugin-eval.scm— definesplugin-preprocesswhich readsplugin-supports-math-input-ref