Skip to content

Fix Issue 2734 (Notecards Document card create fails) by fixing logic error in \TEDIT.INSTALL.PIECE - #2743

Closed
fghalasz wants to merge 1 commit into
masterfrom
fgh_fix2734
Closed

fghalasz wants to merge 1 commit into
masterfrom
fgh_fix2734

Conversation

@fghalasz

@fghalasz fghalasz commented Sep 4, 2026

Copy link
Copy Markdown
Member

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.

@fghalasz
fghalasz requested a review from rmkaplan September 4, 2026 05:41
@fghalasz fghalasz self-assigned this Sep 4, 2026
@fghalasz fghalasz added this to tedit Sep 4, 2026
@fghalasz fghalasz added the bug Something isn't working (as per documentation) label Sep 4, 2026
@pamoroso

pamoroso commented Sep 4, 2026

Copy link
Copy Markdown
Member

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.

@rmkaplan

rmkaplan commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

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.

rmkaplan added a commit that referenced this pull request Sep 7, 2026
@rmkaplan

rmkaplan commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

I moved your fix, with some other adjustments, to the TEDIT-STREAM file in #2742 . If that looks good, this can be closed.

@fghalasz

fghalasz commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@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.

@rmkaplan

rmkaplan commented Sep 10, 2026 via email

Copy link
Copy Markdown
Contributor

@fghalasz

Copy link
Copy Markdown
Member Author

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.

@fghalasz fghalasz closed this Sep 11, 2026
@github-project-automation github-project-automation Bot moved this to Done in tedit Sep 11, 2026
rmkaplan added a commit that referenced this pull request Sep 14, 2026
…cumentation (#2742)

* Improves  tracking in Tedit windows, Tedit follows WHENOPERATEDONFN documentation
* Incorporates the fix to \TEDIT.INSTALL.PIECE from  PR #2743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working (as per documentation)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Not an array error when scrolling Document card of DEMO.NOTEFILE in NoteCards

3 participants