Skip to content

Commit

Permalink
vis: do not indent empty lines when right shifting with >
Browse files Browse the repository at this point in the history
The exception being when the range is a single line.
  • Loading branch information
martanne committed Mar 22, 2017
1 parent 617f5e2 commit ad85748
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vis-operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ static size_t op_shift_right(Vis *vis, Text *txt, OperatorContext *c) {
/* if range ends at the begin of a line, skip line break */
if (pos == c->range.end)
pos = text_line_prev(txt, pos);
bool multiple_lines = text_line_prev(txt, pos) >= c->range.start;

do {
prev_pos = pos = text_line_begin(txt, pos);
if (text_insert(txt, pos, tab, tablen) && pos <= c->pos)
size_t end = text_line_end(txt, pos);
prev_pos = pos = text_line_begin(txt, end);
if ((!multiple_lines || pos != end) &&
text_insert(txt, pos, tab, tablen) && pos <= c->pos)
newpos += tablen;
pos = text_line_prev(txt, pos);
} while (pos >= c->range.start && pos != prev_pos);
Expand Down

0 comments on commit ad85748

Please sign in to comment.