mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
Fix assertion failure triple-clicking line with quote in last column
By default, triple-click tries to select quoted strings within a logical line. This also works if the line spans multiple screen lines. If there is a quote character in the last column: printf %"$COLUMNS"s \'; printf wrapped; sleep inf and I triple-click on the following soft-wrapped line, there's an assertion failure because the column next to the quote is out of range. The quote position has been found by walking at least one cell backwards from "pos". This means that if the quote position is in the very last column, there must be a row below. Also move the assertion to be a pre-condition, though that's debatable.
This commit is contained in:
parent
1fce0e69f5
commit
5cb8ff2e9c
1 changed files with 10 additions and 3 deletions
13
selection.c
13
selection.c
|
|
@ -19,6 +19,7 @@
|
|||
#include "char32.h"
|
||||
#include "commands.h"
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include "extract.h"
|
||||
#include "grid.h"
|
||||
#include "misc.h"
|
||||
|
|
@ -558,9 +559,15 @@ selection_find_quote_left(struct terminal *term, struct coord *pos,
|
|||
if (*quote_char == '\0' ? (wc == '"' || wc == '\'')
|
||||
: wc == *quote_char)
|
||||
{
|
||||
pos->row = next_row;
|
||||
pos->col = next_col + 1;
|
||||
xassert(pos->col < term->cols);
|
||||
xassert(next_col + 1 <= term->cols);
|
||||
if (next_col + 1 == term->cols) {
|
||||
xassert(next_row < pos->row);
|
||||
pos->row = next_row + 1;
|
||||
pos->col = 0;
|
||||
} else {
|
||||
pos->row = next_row;
|
||||
pos->col = next_col + 1;
|
||||
}
|
||||
|
||||
*quote_char = wc;
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue