Improve and fix last changes
* src/xdisp.c (get_narrowed_width): Use WINDOW_RIGHT_FRINGE_WIDTH, which works both for character-only terminals and for GUI frames without fringes. (get_nearby_bol_pos): Instead of searching for BOL in [pos-500000..pos], gradually extend the region, starting with [pos-500..pos]. This is much faster in buffers with some long lines in the middle of lots of short lines.
This commit is contained in:
parent
2093e010dc
commit
dce08cf05c
1 changed files with 21 additions and 12 deletions
23
src/xdisp.c
23
src/xdisp.c
|
@ -3580,14 +3580,14 @@ init_iterator (struct it *it, struct window *w,
|
||||||
static int
|
static int
|
||||||
get_narrowed_width (struct window *w)
|
get_narrowed_width (struct window *w)
|
||||||
{
|
{
|
||||||
bool term = EQ (Fterminal_live_p (Qnil), Qt);
|
|
||||||
/* In a character-only terminal, only one font size is used, so we
|
/* In a character-only terminal, only one font size is used, so we
|
||||||
can use a smaller factor. */
|
can use a smaller factor. */
|
||||||
int fact = term ? 2 : 3;
|
int fact = EQ (Fterminal_live_p (Qnil), Qt) ? 2 : 3;
|
||||||
/* In a character-only terminal, subtract 1 from the width for the
|
/* If the window has no fringes (in a character-only terminal or in
|
||||||
|
a GUI frame without fringes), subtract 1 from the width for the
|
||||||
'\' line wrapping character. */
|
'\' line wrapping character. */
|
||||||
int width = window_body_width (w, WINDOW_BODY_IN_CANONICAL_CHARS)
|
int width = window_body_width (w, WINDOW_BODY_IN_CANONICAL_CHARS)
|
||||||
- (term ? 1 : 0);
|
- (WINDOW_RIGHT_FRINGE_WIDTH (w) == 0 ? 1 : 0);
|
||||||
return fact * max (1, width);
|
return fact * max (1, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3616,17 +3616,26 @@ static ptrdiff_t
|
||||||
get_nearby_bol_pos (ptrdiff_t pos)
|
get_nearby_bol_pos (ptrdiff_t pos)
|
||||||
{
|
{
|
||||||
ptrdiff_t start, pos_bytepos, cur, next, found, bol = 0;
|
ptrdiff_t start, pos_bytepos, cur, next, found, bol = 0;
|
||||||
start = pos - 500000 < BEGV ? BEGV : pos - 500000;
|
int dist;
|
||||||
pos_bytepos = CHAR_TO_BYTE (pos);
|
for (dist = 500; dist <= 500000; dist *= 10)
|
||||||
|
{
|
||||||
|
pos_bytepos = pos == BEGV ? BEGV_BYTE : CHAR_TO_BYTE (pos);
|
||||||
|
start = pos - dist < BEGV ? BEGV : pos - dist;
|
||||||
for (cur = start; cur < pos; cur = next)
|
for (cur = start; cur < pos; cur = next)
|
||||||
{
|
{
|
||||||
next = find_newline1 (cur, CHAR_TO_BYTE (cur), pos, pos_bytepos,
|
next = find_newline1 (cur, CHAR_TO_BYTE (cur),
|
||||||
|
pos, pos_bytepos,
|
||||||
1, &found, NULL, false);
|
1, &found, NULL, false);
|
||||||
if (found)
|
if (found)
|
||||||
bol = next;
|
bol = next;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (bol)
|
||||||
|
return bol;
|
||||||
|
else
|
||||||
|
pos = pos - dist < BEGV ? BEGV : pos - dist;
|
||||||
|
}
|
||||||
return bol;
|
return bol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue