| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "copy.h" | ||
| 2 | #include "block-iter.h" | ||
| 3 | #include "change.h" | ||
| 4 | #include "insert.h" | ||
| 5 | #include "move.h" | ||
| 6 | #include "selection.h" | ||
| 7 | |||
| 8 | 6 | void paste(Clipboard *clip, View *view, PasteLinesType type, bool move_after) | |
| 9 | { | ||
| 10 |
1/2✓ Branch 0 (2→3) taken 6 times.
✗ Branch 1 (2→24) not taken.
|
6 | if (clip->len == 0) { |
| 11 | return; | ||
| 12 | } | ||
| 13 | |||
| 14 | 6 | BUG_ON(!clip->buf); | |
| 15 |
4/4✓ Branch 0 (5→6) taken 5 times.
✓ Branch 1 (5→7) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 3 (6→9) taken 4 times.
|
6 | if (!clip->is_lines || type == PASTE_LINES_INLINE) { |
| 16 | 2 | insert_text(view, clip->buf, clip->len, move_after); | |
| 17 | 2 | return; | |
| 18 | } | ||
| 19 | |||
| 20 | 4 | size_t del_count = 0; | |
| 21 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→12) taken 4 times.
|
4 | if (view->selection) { |
| 22 | ✗ | del_count = prepare_selection(view); | |
| 23 | ✗ | unselect(view); | |
| 24 | } | ||
| 25 | |||
| 26 | 4 | const long x = view_get_preferred_x(view); | |
| 27 |
1/2✓ Branch 0 (13→14) taken 4 times.
✗ Branch 1 (13→19) not taken.
|
4 | if (!del_count) { |
| 28 |
1/2✓ Branch 0 (14→15) taken 4 times.
✗ Branch 1 (14→16) not taken.
|
4 | if (type == PASTE_LINES_BELOW_CURSOR) { |
| 29 | 4 | block_iter_eat_line(&view->cursor); | |
| 30 | } else { | ||
| 31 | ✗ | BUG_ON(type != PASTE_LINES_ABOVE_CURSOR); | |
| 32 | ✗ | block_iter_bol(&view->cursor); | |
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | 4 | buffer_replace_bytes(view, del_count, clip->buf, clip->len); | |
| 37 | |||
| 38 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 4 times.
|
4 | if (move_after) { |
| 39 | ✗ | block_iter_skip_bytes(&view->cursor, clip->len); | |
| 40 | } else { | ||
| 41 | // Try to keep cursor column | ||
| 42 | 4 | move_to_preferred_x(view, x); | |
| 43 | } | ||
| 44 | |||
| 45 | // New preferred_x | ||
| 46 | 4 | view_reset_preferred_x(view); | |
| 47 | } | ||
| 48 |