diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-15 16:39:09 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-15 16:39:09 +0200 |
| commit | 472c559a273d3c7b0f5ee92260c5544bc3d74576 (patch) | |
| tree | 84f5df4e91c6ac95f35c35e0ad808e08ca8d82fe | |
| parent | 63f26c666b9497f1ea045b809a0479930498984a (diff) | |
| download | vis-472c559a273d3c7b0f5ee92260c5544bc3d74576.tar.gz vis-472c559a273d3c7b0f5ee92260c5544bc3d74576.tar.xz | |
vis: calculate auto indent for all cursors individually
| -rw-r--r-- | vis.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -1111,10 +1111,9 @@ void vis_insert_tab(Vis *vis) { } } -static void copy_indent_from_previous_line(Win *win) { - View *view = win->view; +static void copy_indent_from_previous_line(Win *win, Cursor *cur) { Text *text = win->file->text; - size_t pos = view_cursor_get(view); + size_t pos = view_cursors_pos(cur); size_t prev_line = text_line_prev(text, pos); if (pos == prev_line) return; @@ -1125,7 +1124,8 @@ static void copy_indent_from_previous_line(Win *win) { if (!buf) return; len = text_bytes_get(text, begin, len, buf); - vis_insert_key(win->vis, buf, len); + text_insert(text, pos, buf, len); + view_cursors_scroll_to(cur, pos + len); free(buf); } @@ -1133,8 +1133,11 @@ void vis_insert_nl(Vis *vis) { const char *nl = text_newline_char(vis->win->file->text); vis_insert_key(vis, nl, strlen(nl)); - if (vis->autoindent) - copy_indent_from_previous_line(vis->win); + if (!vis->autoindent) + return; + + for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c)) + copy_indent_from_previous_line(vis->win, c); } Regex *vis_regex(Vis *vis, const char *pattern) { |
