Tab finishes a word somebody started

The first word of a line, against the shell's fifteen commands. One match goes in
with a space after it, because a word that can only be one thing is finished.
Several are folded into their longest common prefix and that goes in, which is
the most that can be said without guessing which was meant - and if that adds
nothing, the matches are listed and the line put back underneath.

THE LINE COMING BACK IS THE HALF I EXPECTED TO BE HARD and it was already
solved. The prompt has been reprinted somewhere else entirely, so the editor's
idea of where the line begins is wrong - but editAnchor works that out backwards
from where printing ended, precisely so it survives the screen moving. Listing is
a redraw it already knew how to do.

editInsert became editPut, a routine, because completing a word puts in several
characters and every one of them is that. Which cost a bug immediately: the old
inline code left the insertion point in A, and a RET puts A back to what the
caller had.

Two more bugs worth naming, both mine and both the same shape - a pointer that
had moved:

THE CANDIDATE'S START HAS TO BE KEPT. The comparison walks DP3 through the name
as it matches, so by the time a match is declared, DP3 points at the part AFTER
what was typed - and that is what got copied. "he" completed to "he" because the
answer taken was "lp".

AND THE INSERTION STOPS AT OR PAST, not exactly equal. With the wrong answer the
two counters passed each other and the loop ran off the end of the buffer,
filling the line with whatever was next in memory. They cannot pass each other
now, and the branch stays, because the cheaper failure is worth nothing.

MY OWN TEST HAD A HOLE and breaking the code found it. The later-word case
pressed Tab after a space, where there is nothing to finish anyway, so it passed
whether or not the shell checked which word it was on. It types "echo he" now,
which would become "echo help" if it did not.

The assembler's label table went past 1024 and is doubled. A ceiling reached
once will be reached again, and it is pointers into source already in memory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-01 17:43:48 -04:00
co-authored by Claude Opus 5
parent 749fef8ce2
commit bb065fe221
7 changed files with 615 additions and 45 deletions
+14
View File
@@ -375,6 +375,20 @@ cosmosEditKeys | CosmOS/Source/cosmos.asm | run | cosmosEdi
# the tail of the long one on the screen unless something covers it, and one space - which
# is all a Delete ever needs - covers nothing.
cosmosHistory | CosmOS/Source/cosmos.asm | run | cosmosHistory.in | - | disks/cosmos.img
# Tab finishing a word somebody started, which is a thing an eight bit shell could not do
# for a structural reason rather than a hard one: it never saw the keystroke, so there was no
# moment at which half a word existed and the system knew.
#
# Every case is here. One match goes in with a space after it. Four that agree on nothing
# more are listed and the line put back underneath - and the line coming back is the half
# worth watching, because the prompt has been reprinted somewhere else and the editor's idea
# of where the line starts has to be asked again rather than remembered. Nothing typed and
# nothing matching both do nothing quietly, and a second Tab later in the line does nothing
# because finishing an argument is not built yet.
#
# The last line is the one that says it works on what is actually there rather than on what
# was typed: two backspaces take "help" down to "he", and Tab finishes it again.
cosmosTab | CosmOS/Source/cosmos.asm | run | cosmosTab.in | - | disks/cosmos.img
# The same editing offered to a PROGRAM, through osReadLine. Edit reads its lines that way,
# so a word typed with two letters the wrong way round is put right without starting the line
# again - which is the whole of what A4 buys.