Skip to content

Store virtual text in ref-counted vtext_T to fix undo/redo#19836

Open
h-east wants to merge 1 commit intovim:masterfrom
h-east:fix-textprop-virtual-text-undo
Open

Store virtual text in ref-counted vtext_T to fix undo/redo#19836
h-east wants to merge 1 commit intovim:masterfrom
h-east:fix-textprop-virtual-text-undo

Conversation

@h-east
Copy link
Copy Markdown
Member

@h-east h-east commented Mar 26, 2026

Problem: Virtual text stored in b_textprop_text is not part of the
undo/redo mechanism, causing text mismatch after undo when
IDs are recycled. The b_textprop_text growarray also grows
indefinitely with repeated add/remove.

Solution: Add vtext_T with reference counting and store the pointer
directly in textprop_T.tp_vtext. Remove b_textprop_text.
Increment refcount when saving lines for undo, decrement
when undo entries are freed. Virtual text memory is now
managed per-property and freed when refcount reaches zero.

Fixes: #19680
Fixes: #19681

Problem:  Virtual text stored in b_textprop_text is not part of the
          undo/redo mechanism, causing text mismatch after undo when
          IDs are recycled.  The b_textprop_text growarray also grows
          indefinitely with repeated add/remove.

Solution: Add vtext_T with reference counting and store the pointer
          directly in textprop_T.tp_vtext.  Remove b_textprop_text.
          Increment refcount when saving lines for undo, decrement
          when undo entries are freed.  Virtual text memory is now
          managed per-property and freed when refcount reaches zero.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Virtual text properties consume ever increasing memory as they are added/deleted. Undo/redo can fail for virtual text properties.

1 participant