Skip to content

Read the clipboard at paste time, and empty it when its file closes, 1.11.0 - #122

Merged
ww-mw merged 2 commits into
mainfrom
clipboard/late-copy
Nov 20, 2026
Merged

ww-mw merged 2 commits into
mainfrom
clipboard/late-copy

Conversation

@ww-mw

@ww-mw ww-mw commented Nov 19, 2026

Copy link
Copy Markdown
Member

A Cut or a Copy now keeps which entries it took, and Paste reads them from their file as they are at that moment. This is how the Data Explorer in MATLAB resolves its clipboard. Before, the paste wrote the value from the moment of the Cut or Copy. So Cut, edit the cut entry, Paste wrote the old value and removed the edited original: the edit ended up nowhere, and a save wrote the old value.

  • Reader per document: each engine (binary and JSON dictionaries, MAT-file / model workspace) registers a reader next to its source deleter (registerSourceReader). The reader finds each taken entry again and takes it again as a copy does (readTaken):

    • a MAT-file variable by its origin token;
    • a dictionary entry by its uuid, which a rename keeps;
    • anything else by its name in its section.

    A cut's delete then names the entry as it is now, so a renamed original moves under its new name.

  • Entries gone by the paste: skipped and named.

    • Some landed: Not pasted: "x" is no longer in a.sldd. (also a warning that stays).
    • None landed: Nothing to paste: "x" is no longer in a.sldd., and the clipboard is emptied.
  • Closing a file: when its last table closes, a clipboard taken from it (Copy or Cut) is emptied and every table is told (closeSource). A Cut no longer pastes after its source closed while leaving the original behind.

  • MAT-file reload: an outside change reads the variables again as new nodes. Each uniquely named variable keeps its token, so a Copy made before the reload still finds it.

  • Drag: unchanged. Nothing can edit between a drag's start and its drop.

Tests

  • New: test/lateClipboard.test.ts (registers and transfer) and a lateCopy.test.ts per engine: Cut/Copy then an edit, a text-view edit (JSON), a rename, a delete, a reload (MAT), and closing the source.
  • Changed to the new behavior: the "tab closed after the cut" cases, the MAT cut/rename/delete cases, the MAT workspace notice, and the shell Log/toast/undo cases. Those used "cut, rename the original, paste" to raise a warning; that now just moves the renamed entry, so they use "copy two, delete one, paste".
  • npm run verify passes (7556 tests).

Follow-ups

  • The extension's test-integration/suite/crossDocumentMove.test.ts pins the old closed-tab result. It changes with the pin bump to v1.11.0.
  • The cut mark is still keyed by the name at the Cut, so a cut entry renamed before the paste loses its dimming. Only how it looks: the paste moves the right entry.

Bumps view to 1.11.0 (new exports SourceRead, SourceReader, goneMessage).

A Cut or a Copy now keeps which entries it took, and a paste asks their
document for them as they are then, the way the Data Explorer in MATLAB
resolves its clipboard. An edit made between a Cut and its paste used to
be lost: the paste wrote the value from the moment of the Cut and then
removed the edited original.

- Each document registers a reader beside its source deleter
  (registers.registerSourceReader). It finds each taken entry again by
  its origin token (a MAT-file variable), its uuid (a dictionary entry,
  through a rename), or its name in its section, and takes it again as
  a copy does (clipboardAction.readTaken). A cut's delete then names the
  entry as it is now, so a renamed original moves under its new name.
- An entry no longer there is skipped and named: "Not pasted: ..." when
  others landed (also a warning), "Nothing to paste: ..." when none did,
  which empties the clipboard (transfer.goneMessage).
- Closing a document's last table empties a clipboard taken from it,
  Copy or Cut, and tells every table (registers.closeSource). A cut no
  longer pastes after its source closed and leaves the original behind.
- A MAT-file reload carries each uniquely named variable's token to the
  variable of that name, so a Copy made before an outside change still
  finds it.
- A drag is unchanged: nothing can edit between its start and its drop.
@ww-mw
ww-mw merged commit 8755319 into main Nov 20, 2026
6 checks passed
@ww-mw
ww-mw deleted the clipboard/late-copy branch November 20, 2026 14:20
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