Repository navigation
Editor: Tab inserts 4 spaces (no TabError) - #13
Merged
Merged
Conversation
…rror LiaScript's code editor defaults to tabSize 2 and useSoftTabs false (Code/View.elm), so Tab inserts a real tab character and a block indented with 4 spaces stops with "TabError: inconsistent use of tabs and spaces". attach() now sets tabSize 4 and soft tabs on each of the block's lia-editor elements, on every re-render (LiaScript recreates them when a slide is shown again). A block's own data-tabsize or data-ace-options still wins, and an editor not yet upgraded is left for the next attach(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
LiaScript's code editor defaults to
tabSize2 anduseSoftTabsfalse (src/elm/Lia/Markdown/Code/View.elm:Editor.tabSize (int "data-tabsize" 2),Editor.useSoftTabs False). So Tab inserts a real tab character, and in a block indented with 4 spaces Python stops withTabError: inconsistent use of tabs and spaces in indentation.Change.
attach()setstabSize = 4anduseSoftTabs = trueon eachlia-editorof the block, through the element's own setters (src/typescript/webcomponents/editor.ts), which pass them on to Ace.attach()runs on every DOM change, so when LiaScript recreates the editors (e.g. a slide shown again), the new editors get the setting again. Elm only re-sets these properties when its own value changes, so it doesn't undo them on a re-render.data-tabsize, or atabSize/useSoftTabsin itsdata-ace-options(LiaScript puts both on thelia-editoras attributes), still wins.attach(). Setting the property before the upgrade would hide the setter.Test (hosted LiaScript player, this branch's macro vs
main's, headless Chrome). In a block indented with 4 spaces: Enter aftertotal = 0, clear the auto-indent, press Tab, type a statement, then ▶ Run.main" \ttotal = total + 0"TabError: inconsistent use of tabs and spaces in indentation" total = total + 0"6<!-- data-tabsize="8" data-ace-options="useSoftTabs=false" -->keeps tab size 8 and hard tabs.node scripts/check-macro.mjspasses.🤖 Generated with Claude Code