diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-11-27 13:57:01 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-11-27 13:57:01 +0100 |
| commit | 1954d5ef9219b5c3c8ba757b0936118fe265d13b (patch) | |
| tree | 0d159fb6db99707524a5f9629b272afd003d9fa3 /main.c | |
| parent | 28481439c06780e2c56d3c2b47711785bcaa25a6 (diff) | |
| download | vis-1954d5ef9219b5c3c8ba757b0936118fe265d13b.tar.gz vis-1954d5ef9219b5c3c8ba757b0936118fe265d13b.tar.xz | |
vis: improve cursor alignment command <C-a>
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1127,15 +1127,16 @@ static const char *cursors_align(Vis *vis, const char *keys, const Arg *arg) { Text *txt = vis_text(vis); int mincol = INT_MAX; for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) { - size_t pos = view_cursors_pos(c); - int col = text_line_char_get(txt, pos); - if (col < mincol) + int col = view_cursors_cell_get(c); + if (col >= 0 && col < mincol) mincol = col; } for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) { - size_t pos = view_cursors_pos(c); - size_t col = text_line_char_set(txt, pos, mincol); - view_cursors_to(c, col); + if (view_cursors_cell_set(c, mincol) == -1) { + size_t pos = view_cursors_pos(c); + size_t col = text_line_char_set(txt, pos, mincol); + view_cursors_to(c, col); + } } return keys; } |
