aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-23 06:08:24 +0800
committerGitHub <noreply@github.com>2024-05-23 06:08:24 +0800
commit5cbd6d9b9f232a6ff22ae3a9af80075404226e4b (patch)
treec17a90a3c65fc89e09bb77547d55ab8d1e161c33 /src/nvim/ops.c
parent3d43bdc81e4e0a7acf60050f1b749429516d30fa (diff)
downloadrneovim-5cbd6d9b9f232a6ff22ae3a9af80075404226e4b.tar.gz
rneovim-5cbd6d9b9f232a6ff22ae3a9af80075404226e4b.tar.bz2
rneovim-5cbd6d9b9f232a6ff22ae3a9af80075404226e4b.zip
vim-patch:9.1.0430: getregionpos() doesn't handle one char selection (#28924)
Problem: getregionpos() doesn't handle one char selection. Solution: Handle startspaces differently when is_oneChar is set. Also add a test for an exclusive charwise selection with multibyte chars (zeertzjq) closes: vim/vim#14825 https://github.com/vim/vim/commit/52a6f348874778cf315b47d9e8b5f818f4b97277
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 707cf5ca9a..5c1e291ac6 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -4253,11 +4253,12 @@ void charwise_block_prep(pos_T start, pos_T end, struct block_def *bdp, linenr_T
{
colnr_T startcol = 0;
colnr_T endcol = MAXCOL;
- bool is_oneChar = false;
colnr_T cs, ce;
char *p = ml_get(lnum);
+
bdp->startspaces = 0;
bdp->endspaces = 0;
+ bdp->is_oneChar = false;
bdp->start_char_vcols = 0;
if (lnum == start.lnum) {
@@ -4287,7 +4288,7 @@ void charwise_block_prep(pos_T start, pos_T end, struct block_def *bdp, linenr_T
&& utf_head_off(p, p + endcol) == 0)) {
if (start.lnum == end.lnum && start.col == end.col) {
// Special case: inside a single char
- is_oneChar = true;
+ bdp->is_oneChar = true;
bdp->startspaces = end.coladd - start.coladd + inclusive;
endcol = startcol;
} else {
@@ -4300,7 +4301,7 @@ void charwise_block_prep(pos_T start, pos_T end, struct block_def *bdp, linenr_T
if (endcol == MAXCOL) {
endcol = ml_get_len(lnum);
}
- if (startcol > endcol || is_oneChar) {
+ if (startcol > endcol || bdp->is_oneChar) {
bdp->textlen = 0;
} else {
bdp->textlen = endcol - startcol + inclusive;