summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-08-01 14:30:32 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-08-01 14:30:32 +0000
commit28b45b6dad1fa7d4ed5f5d3670f6b50a3e0e749b (patch)
tree1105b8b221606caf2de9ccd2f0f7a75f9e9b5d7e /usr.bin
parent159397501fe8c86607c5c0223c996508fca5f3b8 (diff)
Select the correct word for select-word when already at the start of a
word, GitHub issue 1820.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/window-copy.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 1f2ca16264a..9b84df77564 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.228 2019/07/08 20:29:11 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.229 2019/08/01 14:30:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -110,7 +110,7 @@ static void window_copy_cursor_next_word(struct window_mode_entry *,
static void window_copy_cursor_next_word_end(struct window_mode_entry *,
const char *);
static void window_copy_cursor_previous_word(struct window_mode_entry *,
- const char *);
+ const char *, int);
static void window_copy_scroll_up(struct window_mode_entry *, u_int);
static void window_copy_scroll_down(struct window_mode_entry *, u_int);
static void window_copy_rectangle_toggle(struct window_mode_entry *);
@@ -1048,7 +1048,7 @@ window_copy_cmd_previous_matching_bracket(struct window_copy_cmd_state *cs)
tried = 1;
goto retry;
}
- window_copy_cursor_previous_word(wme, "}]) ");
+ window_copy_cursor_previous_word(wme, "}]) ", 1);
}
continue;
}
@@ -1343,7 +1343,7 @@ window_copy_cmd_previous_space(struct window_copy_cmd_state *cs)
u_int np = wme->prefix;
for (; np != 0; np--)
- window_copy_cursor_previous_word(wme, " ");
+ window_copy_cursor_previous_word(wme, " ", 1);
return (WINDOW_COPY_CMD_NOTHING);
}
@@ -1357,7 +1357,7 @@ window_copy_cmd_previous_word(struct window_copy_cmd_state *cs)
ws = options_get_string(s->options, "word-separators");
for (; np != 0; np--)
- window_copy_cursor_previous_word(wme, ws);
+ window_copy_cursor_previous_word(wme, ws, 1);
return (WINDOW_COPY_CMD_NOTHING);
}
@@ -1477,7 +1477,7 @@ window_copy_cmd_select_word(struct window_copy_cmd_state *cs)
data->rectflag = 0;
ws = options_get_string(s->options, "word-separators");
- window_copy_cursor_previous_word(wme, ws);
+ window_copy_cursor_previous_word(wme, ws, 0);
window_copy_start_selection(wme);
window_copy_cursor_next_word_end(wme, ws);
@@ -3314,7 +3314,7 @@ window_copy_cursor_next_word_end(struct window_mode_entry *wme,
/* Move to the previous place where a word begins. */
static void
window_copy_cursor_previous_word(struct window_mode_entry *wme,
- const char *separators)
+ const char *separators, int already)
{
struct window_copy_mode_data *data = wme->data;
u_int px, py;
@@ -3323,25 +3323,27 @@ window_copy_cursor_previous_word(struct window_mode_entry *wme,
py = screen_hsize(data->backing) + data->cy - data->oy;
/* Move back to the previous word character. */
- for (;;) {
- if (px > 0) {
- px--;
- if (!window_copy_in_set(wme, px, py, separators))
- break;
- } else {
- if (data->cy == 0 &&
- (screen_hsize(data->backing) == 0 ||
- data->oy >= screen_hsize(data->backing) - 1))
- goto out;
- window_copy_cursor_up(wme, 0);
-
- py = screen_hsize(data->backing) + data->cy - data->oy;
- px = window_copy_find_length(wme, py);
-
- /* Stop if separator at EOL. */
- if (px > 0 &&
- window_copy_in_set(wme, px - 1, py, separators))
- break;
+ if (already || window_copy_in_set(wme, px, py, separators)) {
+ for (;;) {
+ if (px > 0) {
+ px--;
+ if (!window_copy_in_set(wme, px, py, separators))
+ break;
+ } else {
+ if (data->cy == 0 &&
+ (screen_hsize(data->backing) == 0 ||
+ data->oy >= screen_hsize(data->backing) - 1))
+ goto out;
+ window_copy_cursor_up(wme, 0);
+
+ py = screen_hsize(data->backing) + data->cy - data->oy;
+ px = window_copy_find_length(wme, py);
+
+ /* Stop if separator at EOL. */
+ if (px > 0 &&
+ window_copy_in_set(wme, px - 1, py, separators))
+ break;
+ }
}
}