Closed johnfn closed 8 years ago
How does this sound as a game plan:
clone()
the top HistoryStepNotes:
.
very fast.i
, a
, I
, A
etc. aka: move the cursor first, then apply the changes).HistoryTracker.go(Back|Forward)HistoryStep()
. changes
should probably be private.)Thoughts?
Wow, you really did go for the toughest ones first.
I like the idea of using the HistoryStep for . actions, but what bums me out is that it can't be done in a consistent way. For example, if I have |word differentword
and I do dw
, then HistoryStep will say I deleted 4 characters, but if I hit . I expect to now delete much more than 4 characters. So then we have to special case it just for inserts, and then special case again for inserts that only insert in one place. But then handling things like Visual Block mode become difficult, and multi-cursor actions also become hard.
The way that I currently do . is that I track every action inside of RecordedState. For inserts, every time the user types a letter, I create a new InsertInInsertMode action that tracks the character that was inserted. Then when the user presses ., all the InsertInInsertMode actions are replayed.
The easiest possible way to get autocomplete to work with our current infrastructure would be like this:
historyTracker.addChange
, retrieve the diff from HistoryTracker. This was the text that was inserted when the user pressed tab.Re: Making . fast:
I always start by thinking about the worst possible case when looking for improvements to make. In the case of . the worst possible case isn't . at all, it's macros. (.
is like a baby macro.) I would like a solution that improves both . and supports a fast future implementation of macros (which I plan to implement almost exactly the same way as . - just by repeating each action the user made).
I like your solution, but since macros can have multiple inserts and multiple overlapping deletes, I don't think it can speed them up. Getting macros to be fast would be a good deal of work. The problem currently is that every action that does an insert/delete immediately does the full action when you call exec(), so they take a while to complete, and VSCode doesn't allow us to batch atomic actions if they overlap. I think the correct way to make .
fast would be like this:
It starts to sound a lot like HistoryTracker, actually... hmm
This is fixed already.
This is a toughie; you need to integrate with HistoryTracker to diff the document and see what text got added, then store that with the action somehow.