- Notifications
You must be signed in to change notification settings - Fork750
History API
This refers to the following issues:
Re-removed history_id. Since we will need a separate command to set the history data, it cantake the new history_id followed by the history node data, so this does not need to be part ofthe history node data.
Provide all information necessary for a "Persistent Undo" plugin.
Provide all information necessary for a tool like parinfer-rust to inspectall the changes to the buffer since it was last seen.
Enable for "undojoin"-like functionality: easily amend the current historynode.
Be easy to parse from POSIX shell.
Allow for plugins to implement Vim’s
:earlier
.
Nice to have:
Use one variable, allowing history to be replaced with
set-option
.Have the format be compact, to avoid environment variable limits.
Able to support cursor positions or timestamps for each node in the future.
<parent0> <timepoint0> <redo_child0> <modification0.0> <modification0.1> <modification0.2>...<parent1> <timepoint1> <redo_child1> <modification1.0> <modification1.1>......
- parent<n> (integer)
Index of the parent of node <n>. The parent of node 0 is
-1
.- timepoint<n> (ISO-8601 timestamp in UTC)
The time the history node was first committed.
- redo_child<n> (integer)
Index of the node to which we will move if the user types
U
. Leaf nodesshould have-1
.- modification<n>.<m> (modification)
The <m>th modification for node <n>.
Modifications are represented as `op|coord|text` strings. `text` is at theend so it can contain arbitrary text, including pipe symbols, and still beeasily parsed by shell.
For example:
-1 1 2018-12-31T11:15:56Z0 2 2018-12-31T11:16:12Z '+|1.2|hello world' '-|2.7|foo'1 -1 2018-12-31T11:16:46Z '+|2.2|bar'1 -1 2018-12-31T11:17:03Z '+|7.16|x'
(Quotes are the quotes which might be added by shell expansion, not part ofthe format itself.)
Since each history node consists of a variable number of items, processorswill need to detect the start of the next record by checking if the currentitem is a well-formed integer. We can parse the data in POSIX sh like so:
evalset --"$kak_history"node=-1while [$#-gt 0 ];do node=$(( node+1)) parent=$1shift timepoint=$1shift redo_child=$1shiftwhile [$#-gt 0 ];docase"$1"in [-+]\|*) op="${1%%|*}" tmp="${1#*|}" coord="${tmp%%|*}" text="${tmp#*|}"# Process the modificationshift ;;*[!0-9]*)shift# Ignore something unknown ;;*)break# Start next record ;;esacdonedone
Since modifications are tagged with+
or-
in their first field, we canadd more tags. In the documentation, we warn existing processors to ignoreunknown tags.
The parent of node 0 must be
-1
.Node 0 must not have any modifications.
The graph must be acyclic with respect to parent pointers.
The graph must be fully connected; every node must be reachable from theroot.
Every
redo_child
of an internal node must point to an immediate childnode.Every
redo_child
of a leaf node must be-1
.Working backward from the supplied history ID and the current buffercontents to the root, all modifications which are insertions should bedeletable and all deletions should be insertable. This means that thecoordinate for each exists and the supplied text for insertions is presentat that coordinate.
Given the constructed buffer contents for node 0 created in the previousstep, itshould be possible to reach all leaves by applying the insertions ordeletions in every node.
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV