Few style changes on history exposition code
This commit is contained in:
parent
43dc494e5c
commit
8b6ed26e8c
|
@ -3,6 +3,11 @@
|
||||||
This changelog contains major and/or breaking changes to Kakoune between
|
This changelog contains major and/or breaking changes to Kakoune between
|
||||||
released versions.
|
released versions.
|
||||||
|
|
||||||
|
== Development version
|
||||||
|
|
||||||
|
* Expose history tree through `$kak_history` and
|
||||||
|
`$kak_uncommitted_modifications`
|
||||||
|
|
||||||
== Kakoune 2019.12.10
|
== Kakoune 2019.12.10
|
||||||
|
|
||||||
* Arrow keys and `<home>`, `<end>` are not normal mode commands
|
* Arrow keys and `<home>`, `<end>` are not normal mode commands
|
||||||
|
|
|
@ -221,23 +221,9 @@ void write_to_debug_buffer(StringView str)
|
||||||
|
|
||||||
InplaceString<23> to_string(Buffer::HistoryId id)
|
InplaceString<23> to_string(Buffer::HistoryId id)
|
||||||
{
|
{
|
||||||
if (id == Buffer::HistoryId::Invalid) {
|
if (id == Buffer::HistoryId::Invalid)
|
||||||
InplaceString<23> res;
|
return InplaceString<23>{1, "-"};
|
||||||
res.m_data[0] = '-';
|
|
||||||
res.m_length = 1;
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
return to_string(static_cast<size_t>(id));
|
return to_string(static_cast<size_t>(id));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String format_modification(const Buffer::Modification& modification, Quoting quoting)
|
|
||||||
{
|
|
||||||
auto quote = quoter(quoting);
|
|
||||||
return quote(format("{}{}.{}|{}",
|
|
||||||
modification.type == Buffer::Modification::Type::Insert ? '+' : '-',
|
|
||||||
modification.coord.line, modification.coord.column,
|
|
||||||
modification.content->strview()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String history_as_string(const Vector<Buffer::HistoryNode>& history, Quoting quoting)
|
String history_as_string(const Vector<Buffer::HistoryNode>& history, Quoting quoting)
|
||||||
|
@ -251,15 +237,19 @@ String history_as_string(const Vector<Buffer::HistoryNode>& history, Quoting quo
|
||||||
node.undo_group.empty() ? "" : " ",
|
node.undo_group.empty() ? "" : " ",
|
||||||
undo_group_as_string(node.undo_group, quoting));
|
undo_group_as_string(node.undo_group, quoting));
|
||||||
};
|
};
|
||||||
return join(history |transform(format_history_node), ' ', false);
|
return join(history | transform(format_history_node), ' ', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String undo_group_as_string(const Buffer::UndoGroup& undo_group, Quoting quoting)
|
String undo_group_as_string(const Buffer::UndoGroup& undo_group, Quoting quoting)
|
||||||
{
|
{
|
||||||
auto modification_as_string = [&](const Buffer::Modification& modification) {
|
auto modification_as_string = [&](const Buffer::Modification& modification) {
|
||||||
return format_modification(modification, quoting);
|
auto quote = quoter(quoting);
|
||||||
|
return quote(format("{}{}.{}|{}",
|
||||||
|
modification.type == Buffer::Modification::Type::Insert ? '+' : '-',
|
||||||
|
modification.coord.line, modification.coord.column,
|
||||||
|
modification.content->strview()));
|
||||||
};
|
};
|
||||||
return join(undo_group |transform(modification_as_string), ' ', false);
|
return join(undo_group | transform(modification_as_string), ' ', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,6 @@ void reload_file_buffer(Buffer& buffer);
|
||||||
void write_to_debug_buffer(StringView str);
|
void write_to_debug_buffer(StringView str);
|
||||||
|
|
||||||
InplaceString<23> to_string(Buffer::HistoryId id);
|
InplaceString<23> to_string(Buffer::HistoryId id);
|
||||||
String format_modification(const Buffer::Modification& modification, Quoting quoting);
|
|
||||||
String history_as_string(const Vector<Buffer::HistoryNode>& history, Quoting quoting);
|
String history_as_string(const Vector<Buffer::HistoryNode>& history, Quoting quoting);
|
||||||
String undo_group_as_string(const Buffer::UndoGroup& undo_group, Quoting quoting);
|
String undo_group_as_string(const Buffer::UndoGroup& undo_group, Quoting quoting);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Make our expansion have a predictable timestamp
|
# Make our expansion have a predictable timestamp
|
||||||
hook global ClientClose .* %{
|
hook global ClientClose .* %{
|
||||||
evaluate-commands %sh{
|
nop %sh{
|
||||||
kak -f 'ghf<space>ec$timestamp<esc>2f<space>ec$timestamp<esc>' <kak_quoted_history >tmp
|
kak -f 'ghf<space>ec$timestamp<esc>2f<space>ec$timestamp<esc>' kak_quoted_history
|
||||||
mv tmp kak_quoted_history
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user