Skip to content

Editor: no live completion and no snippets (P31); P29b and the double tap checked - #28

Merged
cedricvogel-leo merged 1 commit into
mainfrom
fix/tests-keep-and-no-snippets
Nov 1, 2026
Merged

cedricvogel-leo merged 1 commit into
mainfrom
fix/tests-keep-and-no-snippets

Conversation

@cedricvogel-leo

@cedricvogel-leo cedricvogel-leo commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Two parts: P31 (completion and snippets off) changes the macro. For P29b (failing doctests) and the double tap, my tests found nothing to fix, so there's no code change for them.

P31: no live completion and no snippets in glpython blocks

Since LiaScript 2.1.1, every executable block completes as one types and expands snippets. if + Enter (or + Tab) became if condition: / # TODO: write code..., also in a docstring.

The macro now sets enableLiveAutocompletion = false and enableSnippets = false on the block's lia-editors. It works the same way as the existing tabSize/useSoftTabs (in indentWithSpaces, run from attach() on every re-render):

  • It only writes when the value differs.
  • It skips an editor that isn't upgraded to LiaScript's element yet.
  • A block's own data-ace-options that names one of the two options wins.

Ctrl+Space stays (enableBasicAutocompletion). It only opens on request; without snippets it offers keywords and the block's own words, and Escape closes it. On the iPad there's usually no Ctrl+Space at all.

README («The macro makes the block's editor indent…») and CLAUDE.md are updated.

Tested (Chrome, headless, hosted LiaScript player, local course version: 1.0.0)

new macro macro on main
Options after loading (single block, both files of a group) live off, snippets off, Ctrl+Space on all on
Docstring line + if + Enter no popup, new line popup, if condition: + # TODO…
Docstring line + if + Tab no popup, 4 spaces popup, snippet
After ▶ with a change still off
Version arrows back twice (2 → 1 → 0) still off
Next slide and back (editors recreated) still off, if + Enter = new line
Block with data-ace-options="enableLiveAutocompletion=true enableSnippets=true" stays on (the course wins)

P29b: «Tests» with failing doctests – not reproduced

The same test as in #27, now with failing doctests, run with the macro from main. I recorded LiaScript's IndexedDB record (code store) right after the click and after the result.

Case Doctests DB right after the click Messages After the result After reload
Single block, comment added fail (3 * x) 1 → 2 versions, active 1 one glpython:test unchanged kept
Group noten.py/main.py, comment in main.py fail 1 → 2, active 1 one glpython:test unchanged kept
Etappe 2 slide 8 (copy, local macro), main.py … / 3 + 7 0 of 6 pass 1 → 2, active 1 one glpython:test unchanged (also 3 s later) kept
Etappe 2 slide 8, hosted course (the exact URL from P29b) 0 of 6 pass 1 → 2, active 1 one glpython:test unchanged kept
Same, Presentation and Slides mode (fragments stepped to {{3}}) 0 of 6 pass one glpython:test kept
Same, + xyz (NameError in every example) 0 of 6 pass 1 → 2 one glpython:test unchanged kept
Sequence on one block: passing change, failing change, failing change, reload after each 6/6, 0/6, 0/6 versions 1, 2, 3 one glpython:test each kept every time

Passing doctests (#27's table) are kept as before.

From LiaScript's source, too: Eval stores the new version (appendVersion → updateAppend) at the click, and the result only updates that version's log. The writes run in Dexie transactions, so they can't overwrite each other.

Double tap on «Tests»: no problem

Two clicks Messages Report
Double click (dblclick) glpython:test, glpython:test one report (the second run replaces the first)
150 ms apart glpython:test, glpython:test one report
400 ms apart glpython:test, glpython:test one report
Two click() calls in the same task (faster than any person) glpython:test, glpython:test one report

LiaScript runs the block's script synchronously inside the click on its run button. So commandAfterLiaRun is used up before the second click can overwrite it: the single slot is enough, and no glpython:run follows. No change.

Manual tests

Chrome on the desktop:

  1. Etappe 2, «Eine Funktion ruft eine andere auf»: in main.py type a docstring line ending in if, press Enter: new line, no popup. The same with Tab: spaces, no snippet.
  2. Same after ▶, after the version arrows, and after going to the next slide and back.
  3. Ctrl+Space still opens a small list on request, and Escape closes it.

iPad (Safari, software and hardware keyboard if available):
4. Same as 1. With the software keyboard: if then the return key gives a new line, no popup.
5. Typing a whole word with the software keyboard's suggestions (QuickType) still works normally.
6. P29b: change main.py so the doctests fail, «Tests», close the tab, open the course again: the change is there.

Follow-ups (not fixed here)

  • P29b remains open on your side. I couldn't make the change get lost. If it happens again, please paste the snippet below into DevTools (Console) on the slide before the reload: it shows how many versions LiaScript stored and the code it keeps.
  • Test harness: after a «Tests» run, a new indexedDB.open from Playwright's page.evaluate sometimes throws SecurityError: Blocked by policy, until a reload. LiaScript itself keeps storing (it holds its connection from loading: verified with a further change and reload). It only matters for scripts that read IndexedDB: read once right after loading.
  • Other non-glpython blocks in a course (e.g. ```text exercises with a LiaScript script) still have live completion; the macro only touches its own block.

Snippet: what LiaScript stored for the slide's code

// In DevTools (Console) on the course's tab, on the slide: what LiaScript has stored for its code blocks.
(async () => {
  const name = decodeURIComponent(location.search.slice(1))
  const section = Number(location.hash.slice(1)) - 1
  const db = await new Promise((ok, ko) => { const r = indexedDB.open(name); r.onsuccess = () => ok(r.result); r.onerror = ko })
  const rows = await new Promise((ok) => { const r = db.transaction('code').objectStore('code').getAll(); r.onsuccess = () => ok(r.result) })
  for (const row of rows.filter((row) => row.id === section)) {
    row.data.forEach((block, i) => console.log(`DB ${name} | slide ${section + 1}, block ${i} (DB version ${row.version}): ${block.version.length} versions, active ${block.version_active}`,
      block.file.map((file) => `\n--- ${file.name || '(ohne Name)'}\n${file.code}`).join('')))
  }
  if (!rows.some((row) => row.id === section)) console.log(`nothing stored for slide ${section + 1} in ${name}`)
  db.close()
})()

Run it once right after loading the slide, then again after «Tests»: right after the click, the active version should be the new code.

🤖 Generated with Claude Code

LiaScript 2.1.1 turns on live autocompletion and snippets for every
executable block: "if" + Enter or + Tab became a whole statement, also
in a docstring. The macro switches both off, like tabSize, unless the
block's data-ace-options sets them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cedricvogel-leo
cedricvogel-leo merged commit bbafd36 into main Nov 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant