Fix Issue 2734 (Notecards Document card create fails) by fixing logic error in \TEDIT.INSTALL.PIECE - #2743
Fix Issue 2734 (Notecards Document card create fails) by fixing logic error in \TEDIT.INSTALL.PIECE#2743fghalasz wants to merge 1 commit into
Conversation
… error in \TEDIT.INSTALL.PIECE
|
I tested this on Linux Mint 22.1 Cinnamon and it seems to resolve the issue. On one occasion I scrolled the document window while the document was still being generated and got an invalid argument error. However, I can no longer reproduce it. |
|
I think you are correct that the contents (and also PLEN) should be reset if the piece is changed by the subfunction call. But my understanding is that the only time the PC returned from the subfunction would be different than the PC passed in is if there is a sequence of invisible pieces. I haven't seen any instance of invisibility, although I have tried to preserve the code for it. Does Notecards make use of that feature? This fix is to the file on the master branch, but there are other changes to this file in PR #2742. So I'll make the equivalent change on that branch, to avoid merging hassles. |
|
I moved your fix, with some other adjustments, to the TEDIT-STREAM file in #2742 . If that looks good, this can be closed. |
|
@rmkaplan Notecards does indeed use INVISIBLE character looks (see function NCHACKS.MakeTEditCharInvisible) although I have yet to find where this is actually used. In this particular case, however, the PIECE in question does not have CLINVISIBLE set. Instead it is a piece with PLEN of 0. VISIBLEPIECEP "returns" (its a MACRO) NIL when PLEN is 0. Not sure how/where the PIECE of PLEN=0 originates. I probably won't track this any further unless it would be really informative to you to know where a PLEN=0 piece gets created. |
|
A PLEN of 0 is a little scary. I can imagine situations where the algorithms might get confused--landing on difference pieces depending on which direction you are coming from or how the btree is laid out. What if it begins or starts a paragraph, maybe it creates an empty paragraph?
If they are being read from a legacy file, I think I would fix the file reader to prune them out. But it would be helpful, but not worth a lot of effort, to know if it is being created through some current operations. Otherwise, we can wait until something else breaks.
… On Sep 9, 2026, at 4:44 PM, Frank Halasz ***@***.***> wrote:
fghalasz
left a comment
(Interlisp/medley#2743)
<#2743 (comment)>
@rmkaplan <https://github.com/rmkaplan> Notecards does indeed use INVISIBLE character looks (see function NCHACKS.MakeTEditCharInvisible) although I have yet to find where this is actually used.
In this particular case, however, the PIECE in question does not have CLINVISIBLE set. Instead it is a piece with PLEN of 0. VISIBLEPIECEP "returns" (its a MACRO) NIL when PLEN is 0. Not sure how/where the PIECE of PLEN=0 originates. I probably won't track this any further unless it would be really informative to you to know where a PLEN=0 piece gets created.
—
Reply to this email directly, view it on GitHub <#2743?email_source=notifications&email_token=AQSTUJMOCGT5Q2BBJ32IGZT5OHTM7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNRRGAZTGMJXHE4KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5610331798>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJM7SJPEDS6WU3P3ADT5OHTM7AVCNFSNUABFKJSXA33TNF2G64TZHMZDQMJVGE4TSNRUHNEXG43VMU5TKMZUGQ3DIOBUGEZKC5QC>.
You are receiving this because you were mentioned.
|
|
Closing this PR in favor of PR#2742, which includes this fix as well as other changes to \TEDIT.INSTALL.PIECES. Tested PR#2742 w.r.t. Issue #2734. Works just same as this PR. |
This PR fixes Issue 2734 (Notecards Document card create fails). The proximal cause of 2734 is a logic error in \TEDIT.INSTALL.PIECE. Specifically, \TEDIT.INSTALL.PIECE takes a piece as an argument. PC is set to this argument. It then sets PCONTENTS to (PCONTENTS PC). Under certain conditions, it then resets PC to (\TEDIT.FORMATLINE.UPDATELOOKS TSTREAM PC). And later it operates on PCONTENTS differently based on (PTYPE PC). But if the PTYPE of the passed in PC is different from the PTYPE of the reset PC, then the operation fails as it tries to operate on the PCONTENTS (which matches the PTYPE of the passed in PC rather than the reset (i.e., currently set) PC.
Fix is to reset PCONTENTS iff PC gets reset by \TEDIT.FORMATLINE.UPDATELOOK.
@rmkaplan. This fixes the Notecards Document card issue. But I have no idea how to test whether it has any negative effects on the rest of TEdit. I'll leave it to you to check out this fix and judge whether it breaks anything (non-obvious) in TEdit.