Repository navigation
sokol: the clipboard holds the editor's whole code - #3148
Merged
Merged
Conversation
sokol sized its clipboard buffer at 4096 bytes, and its copy keeps buf_size-1 characters: a paste kept only its first 4,095. Code past that lost its tail, while a whole-map copy (65,284 hex characters) and a 64x64 4bpp sprite (4,224) failed the editors' own length checks and pasted nothing. The buffer now takes TIC_CODE_SIZE + 1, the whole code array plus the terminator. The regular 64K cap and every editor payload fit well inside, and the terminator of a full-size paste needs that extra byte. Co-Authored-By: Claude Code <noreply@anthropic.com>
MAX_CODE was sizeof(tic_code), the whole array, so the text and its NUL needed one byte more than the array holds. A pasted, typed or tabbed edit that brought the code to 512K wrote the terminator into cart.binary.data[0] and the state array two bytes past its end. The cap is now sizeof(tic_code) - 1. The insert paths that checked nothing — tab, line duplication, sexpify, find/replace — stop at the cap too, and the paired delimiter inserts count both their bytes. So strlen(code->src) never passes MAX_CODE, and trimWhitespace may write the terminator on its last allowed byte instead of dropping it. Co-Authored-By: Claude Code <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.
sokol sized its clipboard buffer at 4096 bytes, and its copy keeps buf_size-1 characters: a paste kept only its first 4,095. Code past that lost its tail, while a whole-map copy (65,284 hex characters) and a 64x64 4bpp sprite (4,224) failed the editors' own length checks and pasted nothing.
The buffer now takes TIC_CODE_SIZE + 1, the whole code array plus the terminator. The regular 64K cap and every editor payload fit well inside.
The bigger buffer exposed a PRO-only boundary: MAX_CODE was sizeof(tic_code), the whole array, so the text and its NUL needed one byte more than the array holds — a 512K paste wrote the terminator into cart.binary.data[0] and the state array two bytes past its end. The cap is now sizeof(tic_code) - 1, and the insert paths that checked nothing — tab, line duplication, sexpify, find/replace — stop at the cap too, while paired delimiters count both their bytes. trimWhitespace may now write the terminator on its last allowed byte instead of dropping it.
🤖 Generated with Claude Code