mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #12687 from erw7/fix-terminal-overflow
terminal: fix terminal attribute overflow
This commit is contained in:
commit
5f5bd576e5
@ -2804,8 +2804,8 @@ win_line (
|
|||||||
off += col;
|
off += col;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wont highlight after 1024 columns
|
// wont highlight after TERM_ATTRS_MAX columns
|
||||||
int term_attrs[1024] = {0};
|
int term_attrs[TERM_ATTRS_MAX] = { 0 };
|
||||||
if (wp->w_buffer->terminal) {
|
if (wp->w_buffer->terminal) {
|
||||||
terminal_get_line_attributes(wp->w_buffer->terminal, wp, lnum, term_attrs);
|
terminal_get_line_attributes(wp->w_buffer->terminal, wp, lnum, term_attrs);
|
||||||
extra_check = true;
|
extra_check = true;
|
||||||
@ -4172,7 +4172,7 @@ win_line (
|
|||||||
int n = wp->w_p_rl ? -1 : 1;
|
int n = wp->w_p_rl ? -1 : 1;
|
||||||
while (col >= 0 && col < grid->Columns) {
|
while (col >= 0 && col < grid->Columns) {
|
||||||
schar_from_ascii(linebuf_char[off], ' ');
|
schar_from_ascii(linebuf_char[off], ' ');
|
||||||
linebuf_attr[off] = term_attrs[vcol];
|
linebuf_attr[off] = vcol >= TERM_ATTRS_MAX ? 0 : term_attrs[vcol];
|
||||||
off += n;
|
off += n;
|
||||||
vcol += n;
|
vcol += n;
|
||||||
col += n;
|
col += n;
|
||||||
|
@ -32,6 +32,9 @@ EXTERN ScreenGrid default_grid INIT(= SCREEN_GRID_INIT);
|
|||||||
|
|
||||||
#define DEFAULT_GRID_HANDLE 1 // handle for the default_grid
|
#define DEFAULT_GRID_HANDLE 1 // handle for the default_grid
|
||||||
|
|
||||||
|
// Maximum columns for terminal highlight attributes
|
||||||
|
#define TERM_ATTRS_MAX 1024
|
||||||
|
|
||||||
/// Status line click definition
|
/// Status line click definition
|
||||||
typedef struct {
|
typedef struct {
|
||||||
enum {
|
enum {
|
||||||
|
@ -607,6 +607,7 @@ void terminal_get_line_attributes(Terminal *term, win_T *wp, int linenr,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width = MIN(TERM_ATTRS_MAX, width);
|
||||||
for (int col = 0; col < width; col++) {
|
for (int col = 0; col < width; col++) {
|
||||||
VTermScreenCell cell;
|
VTermScreenCell cell;
|
||||||
bool color_valid = fetch_cell(term, row, col, &cell);
|
bool color_valid = fetch_cell(term, row, col, &cell);
|
||||||
|
@ -276,3 +276,12 @@ describe('No heap-buffer-overflow when using', function()
|
|||||||
feed_command('bdelete!')
|
feed_command('bdelete!')
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('No heap-buffer-overflow when', function()
|
||||||
|
it('set nowrap and send long line #11548', function()
|
||||||
|
feed_command('set nowrap')
|
||||||
|
feed_command('autocmd TermOpen * startinsert')
|
||||||
|
feed_command('call feedkeys("4000ai\\<esc>:terminal!\\<cr>")')
|
||||||
|
eq(2, eval('1+1'))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user