diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-02 04:31:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 04:31:17 +0800 |
commit | a0375b68c1803e7453071a20b28249020abe7260 (patch) | |
tree | 7fbf51a11edc2b70d770b6bcbcf338e3c1dfb068 /src/nvim/grid.c | |
parent | 7ade44fefe864961cfa17d1af6c8b8b33eeb4933 (diff) | |
download | rneovim-a0375b68c1803e7453071a20b28249020abe7260.tar.gz rneovim-a0375b68c1803e7453071a20b28249020abe7260.tar.bz2 rneovim-a0375b68c1803e7453071a20b28249020abe7260.zip |
vim-patch:9.0.1598: screenchar() and others are wrong with DBCS 'encoding' (#23872)
Problem: screenchar(), screenchars() and screenstring() do not work
properly when 'encoding' is set to a double-byte encoding.
Solution: Fix the way the bytes of the characters are obtained.
(issue vim/vim#12469)
https://github.com/vim/vim/commit/47eec6716b8621fd43bac8ecc9c19089df26705e
Diffstat (limited to 'src/nvim/grid.c')
-rw-r--r-- | src/nvim/grid.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 76dd2a073a..aa542c5a2f 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -138,8 +138,9 @@ void grid_putchar(ScreenGrid *grid, int c, int row, int col, int attr) grid_puts(grid, buf, row, col, attr); } -/// get a single character directly from grid.chars into "bytes[]". -/// Also return its attribute in *attrp; +/// Get a single character directly from grid.chars into "bytes", which must +/// have a size of "MB_MAXBYTES + 1". +/// If "attrp" is not NULL, return the character's attribute in "*attrp". void grid_getbytes(ScreenGrid *grid, int row, int col, char *bytes, int *attrp) { grid_adjust(&grid, &row, &col); @@ -150,7 +151,9 @@ void grid_getbytes(ScreenGrid *grid, int row, int col, char *bytes, int *attrp) } size_t off = grid->line_offset[row] + (size_t)col; - *attrp = grid->attrs[off]; + if (attrp != NULL) { + *attrp = grid->attrs[off]; + } schar_copy(bytes, grid->chars[off]); } |