Skip to content

Commit

Permalink
Select pasted text on paste
Browse files Browse the repository at this point in the history
This is more consistent with the recently changed ! and <a-!>
behaviour
  • Loading branch information
mawww committed Jul 4, 2022
1 parent ef8a11b commit 266d1c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rc/filetype/c-family.kak
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ define-command -hidden c-family-insert-include-guards %{
evaluate-commands %sh{
case "${kak_opt_c_include_guard_style}" in
ifdef)
echo 'execute-keys ggi<c-r>%<ret><esc>ggI/<esc>xs^.*/<ret>dxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>'
echo 'execute-keys gg"%PI/<esc>xs^.*/<ret>dxs\.<ret>r_A_INCLUDED<esc>xyPPI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>'
;;
pragma)
echo 'execute-keys ggi#pragma<space>once<esc>'
Expand Down
11 changes: 7 additions & 4 deletions src/normal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -683,10 +683,13 @@ void paste(Context& context, NormalParams params)
ScopedEdition edition(context);
context.selections().for_each([&](size_t index, Selection& sel) {
auto& str = strings[std::min(strings.size()-1, index)];
if (mode == PasteMode::Replace)
replace(buffer, sel, str);
else
insert(buffer, sel, paste_pos(buffer, sel, mode, linewise), str);
auto& min = sel.min();
auto& max = sel.max();
BufferRange range = (mode == PasteMode::Replace) ?
buffer.replace(min, buffer.char_next(max), str)
: buffer.insert(paste_pos(buffer, sel, mode, linewise), str);
min = range.begin;
max = range.end > range.begin ? buffer.char_prev(range.end) : range.begin;
});
}

Expand Down

0 comments on commit 266d1c3

Please sign in to comment.