Do not push jumps implicitely in transient contexts
This should improve performance in draft contexts.
This commit is contained in:
parent
095ccfedb4
commit
b204e773d4
|
@ -100,7 +100,7 @@ define-command -hidden d-indent-on-new-line %~
|
|||
# align to opening paren of previous line
|
||||
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
|
||||
# copy // comments prefix
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o>P<esc> }
|
||||
# indent after a switch's case/default statements
|
||||
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
|
||||
# indent after if|else|while|for
|
||||
|
|
|
@ -64,7 +64,7 @@ define-command -hidden go-indent-on-new-line %~
|
|||
# align to opening paren of previous line
|
||||
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
|
||||
# copy // comments prefix
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o>P<esc> }
|
||||
# indent after a switch's case/default statements
|
||||
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
|
||||
# indent after if|else|while|for
|
||||
|
|
|
@ -30,7 +30,7 @@ define-command -hidden java-indent-on-new-line %~
|
|||
# align to opening paren of previous line
|
||||
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
|
||||
# copy // comments prefix
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o>P<esc> }
|
||||
# indent after a switch's case/default statements
|
||||
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
|
||||
# indent after keywords
|
||||
|
|
|
@ -81,7 +81,7 @@ define-command -hidden perl-indent-on-new-line %~
|
|||
# align to opening paren of previous line
|
||||
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
|
||||
# copy // comments prefix
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
|
||||
try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o>P<esc> }
|
||||
# indent after a switch's case/default statements
|
||||
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
|
||||
# indent after if|else|while|for
|
||||
|
|
|
@ -1669,19 +1669,20 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
|
|||
|
||||
if (not draft)
|
||||
{
|
||||
c.selections_write_only() = SelectionList(c.buffer(), new_sels);
|
||||
c.selections_write_only() = SelectionList(c.buffer(), std::move(new_sels));
|
||||
c.selections().sort_and_merge_overlapping();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto original_jump_list = draft ? Optional<JumpList>{} : c.jump_list();
|
||||
auto jump = draft ? Optional<SelectionList>{} : c.selections();
|
||||
const bool transient = c.flags() & Context::Flags::Transient;
|
||||
auto original_jump_list = transient ? Optional<JumpList>{} : c.jump_list();
|
||||
auto jump = transient ? Optional<SelectionList>{} : c.selections();
|
||||
|
||||
func(parser, c);
|
||||
|
||||
// If the jump list got mutated, collapse all jumps into a single one from original selections
|
||||
if (not draft and c.jump_list() != *original_jump_list)
|
||||
if (not transient and c.jump_list() != *original_jump_list)
|
||||
{
|
||||
original_jump_list->push(std::move(*jump));
|
||||
if (c.jump_list() != *original_jump_list)
|
||||
|
|
|
@ -119,7 +119,11 @@ public:
|
|||
Flags flags() const { return m_flags; }
|
||||
|
||||
JumpList& jump_list() { return m_jump_list; }
|
||||
void push_jump() { m_jump_list.push(selections()); }
|
||||
void push_jump(bool force = false)
|
||||
{
|
||||
if (force or not (m_flags & Flags::Transient))
|
||||
m_jump_list.push(selections());
|
||||
}
|
||||
|
||||
template<typename Func>
|
||||
void set_last_select(Func&& last_select) { m_last_select = std::forward<Func>(last_select); }
|
||||
|
|
|
@ -1522,7 +1522,7 @@ void jump(Context& context, NormalParams params)
|
|||
|
||||
void push_selections(Context& context, NormalParams)
|
||||
{
|
||||
context.push_jump();
|
||||
context.push_jump(true);
|
||||
context.print_status({ format("saved {} selections", context.selections().size()),
|
||||
context.faces()["Information"] });
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user