diff --git a/input.c b/input.c index 9d1ee3e1e..d32b600c5 100644 --- a/input.c +++ b/input.c @@ -3305,6 +3305,9 @@ input_osc_133(struct input_ctx *ictx, const char *p) gl->flags |= GRID_LINE_SECOND_PROMPT; else gl->flags |= GRID_LINE_START_PROMPT; + log_debug("%s: osc133 %s at %u,%u", __func__, + input_osc_133_secondary_prompt(p) ? "secondary prompt" : + "prompt", s->cx, line); } } if (wp != NULL) { @@ -3321,6 +3324,8 @@ input_osc_133(struct input_ctx *ictx, const char *p) gl->flags |= GRID_LINE_SECOND_PROMPT; else gl->flags |= GRID_LINE_START_PROMPT; + log_debug("%s: osc133 prompt at %u,%u", __func__, s->cx, + line); } } break; @@ -3329,12 +3334,16 @@ input_osc_133(struct input_ctx *ictx, const char *p) if (gl != NULL && !(gl->flags & GRID_LINE_START_COMMAND)) { gl->flags |= GRID_LINE_START_COMMAND; gl->osc133_data.cmd_col = s->cx; + log_debug("%s: osc133 command at %u,%u", __func__, s->cx, + line); } break; case 'C': if (gl != NULL && !(gl->flags & GRID_LINE_START_OUTPUT)) { gl->flags |= GRID_LINE_START_OUTPUT; gl->osc133_data.out_start_col = s->cx; + log_debug("%s: osc133 output start at %u,%u", __func__, s->cx, + line); } if (wp != NULL) { wp->cmd_start_time = time(NULL); @@ -3358,6 +3367,8 @@ input_osc_133(struct input_ctx *ictx, const char *p) gl->flags |= GRID_LINE_END_OUTPUT_STATUS; gl->osc133_data.out_end_col = s->cx; gl->osc133_data.exit_status = status; + log_debug("%s: osc133 output end at %u,%u (status %d)", + __func__, s->cx, line, status); } break; } diff --git a/window-copy.c b/window-copy.c index 5ef10063c..66b9702ce 100644 --- a/window-copy.c +++ b/window-copy.c @@ -4143,6 +4143,7 @@ window_copy_find_output_range(struct window_mode_entry *wme, u_int *sx, if (data->source == NULL) return (0); window_copy_cursor_source(wme, &cursor_x, &cursor_y); + log_debug("%s: cursor at %u,%u", __func__, cursor_x, cursor_y); gd = data->source->grid; total = gd->hsize + gd->sy; @@ -4156,8 +4157,11 @@ window_copy_find_output_range(struct window_mode_entry *wme, u_int *sx, prompt_y = y; prompt_x = gl->osc133_data.prompt_col; } - if (prompt_y == UINT_MAX) + if (prompt_y == UINT_MAX) { + log_debug("%s: no osc133 prompt before cursor", __func__); return (0); + } + log_debug("%s: prompt at %u,%u", __func__, prompt_x, prompt_y); for (y = prompt_y; y < total; y++) { gl = grid_get_line(gd, y); @@ -4179,19 +4183,29 @@ window_copy_find_output_range(struct window_mode_entry *wme, u_int *sx, } if (!found_start) { /* At the live prompt, use the most recent command output. */ - if (cursor_y == screen_hsize(data->source) + data->source->cy) + if (cursor_y == screen_hsize(data->source) + data->source->cy) { + log_debug("%s: no output after live prompt", __func__); return (window_copy_find_previous_output_range(data->source, sx, sy, ex, ey)); + } + log_debug("%s: no osc133 output after prompt", __func__); return (0); } if (!found_end) { - if (y != total) + if (y != total) { + log_debug("%s: output interrupted by next prompt", __func__); return (0); + } window_copy_output_end(data->source, ex, ey); } if (cursor_y > *ey || (cursor_y == *ey && - (found_end ? cursor_x >= *ex : cursor_x > *ex))) + (found_end ? cursor_x >= *ex : cursor_x > *ex))) { + log_debug("%s: cursor after output end %u,%u", __func__, *ex, + *ey); return (0); + } + log_debug("%s: output from %u,%u to %u,%u", __func__, *sx, *sy, + *ex, *ey); return (1); }