You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ShadowVim currently has a very straightforward approach to synchronizing changes between Neovim and Xcode. It is not very performant nor visually appealing.
⚠️ Fixing this is not high on my priority list, as I'd like to integrate more Nvim features first (e.g. command line). If you're enjoying ShadowVim and wish to give back, please consider giving a hand on the following areas of improvements.
Character instead of line-wise changes
The main reason for the visual artifacts is that Neovim sends line-wise change events. So every time you do a change, ShadowVim will update whole lines in Xcode.
lines.mov
A possible fix would be to resolve character indexes instead of line ones to apply a lines change event, here:
I already added a basic optim to perform character-wise changes only when modifying the end of a line, to make it more bearable when inserting a lot of text:
This is straightforward, thanks to CollectionDifference. A downside, besides the general performance, is that Nvim registers this as a lot of separate change events instead of a compound one. This is very visible when undoing the change.
For example in the following video, I'm inserting an Xcode snippet, then hit u to undo the change, then C-r to redo it. An improvement could be to analyze the CompletionDifference to group consecutive line changes and send them to Nvim in one go.
changes-ui.mov
Grouping Neovim's buf_lines_event
Sometimes Neovim sends in one go multiple buffer change events (buf_lines_event) changing the same line multiple times (character by character). You can see this when triggering Neovim's completion with C-n, like in the following video.
ShadowVim applies the changes in order, which is of course useless and inefficient in this case. A possible optimization would be to coalesce events changing the same lines and received in a really short span.
To know when to stop coalescing events, we can listened to the flushredraw event in the UI protocol.
buf_lines_event.mov
The text was updated successfully, but these errors were encountered:
buf_lines_events are applied on an internal buffer and a diff is computed when receiving a flush UI event. This essentially solves the problem exhibited above without explicitly coalescing the buf_lines_events.
UI line diffs are partially coalesced, when:
Consecutive lines are added/deleted.
A single line is both added and modified (basically when entering a character).
ShadowVim currently has a very straightforward approach to synchronizing changes between Neovim and Xcode. It is not very performant nor visually appealing.
Character instead of line-wise changes
The main reason for the visual artifacts is that Neovim sends line-wise change events. So every time you do a change, ShadowVim will update whole lines in Xcode.
lines.mov
A possible fix would be to resolve character indexes instead of line ones to apply a lines change event, here:
ShadowVim/Sources/Mediator/Buffer/BufferMediator.swift
Line 263 in d745f68
I already added a basic optim to perform character-wise changes only when modifying the end of a line, to make it more bearable when inserting a lot of text:
ShadowVim/Sources/Mediator/Buffer/BufferMediator.swift
Lines 288 to 290 in d745f68
Grouping line changes
When modifying several lines of changes natively from Xcode (e.g. after inserting an Xcode snippet or pasting content from the pasteboard with ⌘V), they are applied line by line back to Nvim, after computing a diff from the current Nvim state.
This is straightforward, thanks to
CollectionDifference
. A downside, besides the general performance, is that Nvim registers this as a lot of separate change events instead of a compound one. This is very visible when undoing the change.For example in the following video, I'm inserting an Xcode snippet, then hit
u
to undo the change, then C-r to redo it. An improvement could be to analyze theCompletionDifference
to group consecutive line changes and send them to Nvim in one go.changes-ui.mov
Grouping Neovim's
buf_lines_event
Sometimes Neovim sends in one go multiple buffer change events (
buf_lines_event
) changing the same line multiple times (character by character). You can see this when triggering Neovim's completion with C-n, like in the following video.ShadowVim applies the changes in order, which is of course useless and inefficient in this case. A possible optimization would be to coalesce events changing the same lines and received in a really short span.
To know when to stop coalescing events, we can listened to the
flush
redraw
event in the UI protocol.buf_lines_event.mov
The text was updated successfully, but these errors were encountered: