I just pushed a change to kakoune-state-save that removes the state-save-reg-sync
command.
Certain Kakoune registers — the ones that represent prompt history, like colon
for the normal command prompt — will merge new values into the existing register contents, instead of just replacing them. So if you run:
reg a foo
reg a bar
echo %reg{a}
…then you will see “bar”, but if you run:
reg colon foo
reg colon bar
echo %reg{colon}
…you will see “reg colon foo foo reg colon bar bar echo %reg{colon}” because it contains the commands you typed as well as the values you manually inserted with :reg colon
.
So when I made kakoune-state-save, I created state-save-reg-sync
that would load a history register from disk (automatically merging it into the current session’s history) and then immediately save the result back out. The idea was, if you had multiple Kakoune sessions open, one session’s history wouldn’t clobber the other.
Unfortunately, it turns out there’s an additional wrinkle to register merging - history registers are limited to 100 items, so if you load 100 items from disk, then whatever was previously in the register gets crowded out. As a result, instead of merging the current session’s history with the history on disk, state-save-reg-sync
would replace the current session’s history. Once you’d written 100 commands, no newer command could ever be stored.
Instead of state-save-reg-sync
, I now recommend using state-save-reg-load
in a KakBegin
hook, and state-save-reg-save
in a KakEnd
hook. This runs the risk of clobbering data if you have multiple sessions running at the same time, but better to risk losing some data than to guarantee losing all of it.
I also filed #3354 for a smarter way to merge history registers. If it gets fixed someday, I’ll add state-save-reg-sync
back in.