From 1954d5ef9219b5c3c8ba757b0936118fe265d13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 27 Nov 2015 13:57:01 +0100 Subject: vis: improve cursor alignment command --- main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 185aa94..35d2f41 100644 --- a/main.c +++ b/main.c @@ -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; } -- cgit v1.2.3