vim --clean test.vim -S test.vim, withvim9script colorscheme habamax prop_type_add('test', {highlight: 'ErrorMsg'}) prop_add(1, 0, { type: 'test', text: 'The quick brown fox jumps over the lazy dog', text_align: 'below', text_padding_left: 4, }) prop_add(1, 0, { type: 'test', text: 'The quick brown fox jumps over the lazy dog', text_align: 'below', text_padding_left: 4, }) prop_add(1, 0, { type: 'test', text: 'The quick brown fox jumps over the lazy dog', text_align: 'below', text_padding_left: 4, }) prop_type_delete('test') normal! G
gg, then press j.I'm not sure what the correct behavior should be. Maybe: when a text-property
type is deleted with prop_type_delete('mytype'), all text-properties using this
type should be removed as well. If no bufnr is passed to prop_type_delete(),
this would mean removing all text-properties in all buffers.
I encountered this bug after removing text-properties while the buffer was in
one state, and then running :undo to go back to an earlier state. It resulted
in text-properties re-appearing in the buffer. This got me thinking: in some use
cases this is desired while in other cases text-properties need to be removed
"permanently", i.e. after an :undo they shouldn't re-appear. An example would
be a plugin that provides some kind of syntax highlighting. If the plugin is
turned off, the text-properties need to be removed and shouldn't show up after
:undo.
There are several ways to accomplish this:
listener_add() and call prop_remove() whenever a text-propertyTextChanged instead.prop_type_delete() (currently has bugs).Alternatives:
prop_add() (or prop_type_define()) that tells Vimprop_remove() that tells Vim to remove the9.0.982
Linux
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Closed #11655 as completed via 89469d1.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Thanks for the quick fix. With "buffer state" I meant the current state in the undo history or buffer history, while pressing u or <C-r>. Not sure what else to call it.
So what is the recommended way to permanently remove the text-properties during a vim session? So that the highlightings don't reappear after undo or redo? The easiest way seems to be with prop_type_delete().
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Here's a small example that illustrates what I mean. The script does the following:
Run vim --clean -S test.vim, with:
vim9scriptprop_type_add('test', {highlight: 'ErrorMsg'})
setline(1, 'one two three four') prop_add(1, 9, {type: 'test', length: 5}) &undolevels = &undolevels normal! dw prop_remove({type: 'test', all: true}) undo
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
This is what I expect to happen. Let me repeat:
"Text properties are stored together with the text. Undo and redo
applies to both. This cannot be changed."
In other words: when saving the text for undo, the text properties are saved as well.
When restoring the text with an undo command, the text properties are also restored.
In a way the text properties are part of the text.
Making changes is a linear sequence of events. Undo goes back through those events.
Adding and remove text properties is part of that. It's not like you can create a parallel universe and jump between the two.
Depending on what added the text property, perhaps you can check the changed lines (no matter if it was a new change or an undo) and add/remove text properties for the current text. I can't really think of what else would be done.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
This fix is causing extra full screen redraws.
I've opened a bug to address it: #11666
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()