ime: don’t adjust cursor’s cell-end if it’s equal to the cell-begin

This commit is contained in:
Daniel Eklöf 2020-12-03 18:40:54 +01:00
parent 552b9884b9
commit 001c82fa54
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

18
ime.c
View file

@ -278,19 +278,25 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
/* Bounded by number of screen columns */ /* Bounded by number of screen columns */
cell_begin = min(max(cell_begin, 0), cell_count - 1); cell_begin = min(max(cell_begin, 0), cell_count - 1);
/* Ensure end comes *after* begin, and is bounded by screen */
if (cell_end <= cell_begin)
cell_end = cell_begin + max(wcwidth(term->ime.preedit.cells[cell_begin].wc), 1);
cell_end = min(max(cell_end, 0), cell_count); cell_end = min(max(cell_end, 0), cell_count);
#if 1
if (cell_end < cell_begin)
cell_end = cell_begin;
#else
if (cell_end <= cell_begin) {
cell_end = cell_begin + max(
wcwidth(term->ime.preedit.cells[cell_begin].wc), 1);
}
#endif
LOG_DBG("pre-edit cursor: begin=%d, end=%d", cell_begin, cell_end); LOG_DBG("pre-edit cursor: begin=%d, end=%d", cell_begin, cell_end);
assert(cell_begin >= 0); assert(cell_begin >= 0);
assert(cell_begin < cell_count); assert(cell_begin < cell_count);
assert(cell_end >= 1); assert(cell_begin <= cell_end);
assert(cell_end >= 0);
assert(cell_end <= cell_count); assert(cell_end <= cell_count);
assert(cell_begin < cell_end);
term->ime.preedit.cursor.hidden = false; term->ime.preedit.cursor.hidden = false;
term->ime.preedit.cursor.start = cell_begin; term->ime.preedit.cursor.start = cell_begin;