Mercurial > vim
comparison src/ex_docmd.c @ 10484:c7de1536780a v8.0.0135
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 2 14:27:34 2017 +0100
patch 8.0.0135
Problem: An address relative to the current line, ":.,+3y", does not work
properly on a closed fold. (Efraim Yawitz)
Solution: Correct for including the closed fold. (Christian Brabandt)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 02 Jan 2017 14:30:04 +0100 |
parents | dc9326b58c33 |
children | 89200fa1d174 |
comparison
equal
deleted
inserted
replaced
10483:b6ea664a77ad | 10484:c7de1536780a |
---|---|
135 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) | 135 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) |
136 # define ex_cexpr ex_ni | 136 # define ex_cexpr ex_ni |
137 #endif | 137 #endif |
138 | 138 |
139 static int check_more(int, int); | 139 static int check_more(int, int); |
140 static linenr_T get_address(exarg_T *, char_u **, int addr_type, int skip, int to_other_file); | 140 static linenr_T get_address(exarg_T *, char_u **, int addr_type, int skip, int to_other_file, int address_count); |
141 static void get_flags(exarg_T *eap); | 141 static void get_flags(exarg_T *eap); |
142 #if !defined(FEAT_PERL) \ | 142 #if !defined(FEAT_PERL) \ |
143 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ | 143 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ |
144 || !defined(FEAT_TCL) \ | 144 || !defined(FEAT_TCL) \ |
145 || !defined(FEAT_RUBY) \ | 145 || !defined(FEAT_RUBY) \ |
1789 int did_sandbox = FALSE; | 1789 int did_sandbox = FALSE; |
1790 #endif | 1790 #endif |
1791 cmdmod_T save_cmdmod; | 1791 cmdmod_T save_cmdmod; |
1792 int ni; /* set when Not Implemented */ | 1792 int ni; /* set when Not Implemented */ |
1793 char_u *cmd; | 1793 char_u *cmd; |
1794 int address_count = 1; | |
1794 | 1795 |
1795 vim_memset(&ea, 0, sizeof(ea)); | 1796 vim_memset(&ea, 0, sizeof(ea)); |
1796 ea.line1 = 1; | 1797 ea.line1 = 1; |
1797 ea.line2 = 1; | 1798 ea.line2 = 1; |
1798 #ifdef FEAT_EVAL | 1799 #ifdef FEAT_EVAL |
2013 | 2014 |
2014 case 't': if (checkforcmd(&p, "tab", 3)) | 2015 case 't': if (checkforcmd(&p, "tab", 3)) |
2015 { | 2016 { |
2016 #ifdef FEAT_WINDOWS | 2017 #ifdef FEAT_WINDOWS |
2017 long tabnr = get_address(&ea, &ea.cmd, ADDR_TABS, | 2018 long tabnr = get_address(&ea, &ea.cmd, ADDR_TABS, |
2018 ea.skip, FALSE); | 2019 ea.skip, FALSE, 1); |
2019 if (tabnr == MAXLNUM) | 2020 if (tabnr == MAXLNUM) |
2020 cmdmod.tab = tabpage_index(curtab) + 1; | 2021 cmdmod.tab = tabpage_index(curtab) + 1; |
2021 else | 2022 else |
2022 { | 2023 { |
2023 if (tabnr < 0 || tabnr > LAST_TAB_NR) | 2024 if (tabnr < 0 || tabnr > LAST_TAB_NR) |
2173 break; | 2174 break; |
2174 #endif | 2175 #endif |
2175 } | 2176 } |
2176 ea.cmd = skipwhite(ea.cmd); | 2177 ea.cmd = skipwhite(ea.cmd); |
2177 lnum = get_address(&ea, &ea.cmd, ea.addr_type, ea.skip, | 2178 lnum = get_address(&ea, &ea.cmd, ea.addr_type, ea.skip, |
2178 ea.addr_count == 0); | 2179 ea.addr_count == 0, address_count++); |
2179 if (ea.cmd == NULL) /* error detected */ | 2180 if (ea.cmd == NULL) /* error detected */ |
2180 goto doend; | 2181 goto doend; |
2181 if (lnum == MAXLNUM) | 2182 if (lnum == MAXLNUM) |
2182 { | 2183 { |
2183 if (*ea.cmd == '%') /* '%' - all lines */ | 2184 if (*ea.cmd == '%') /* '%' - all lines */ |
4361 get_address( | 4362 get_address( |
4362 exarg_T *eap UNUSED, | 4363 exarg_T *eap UNUSED, |
4363 char_u **ptr, | 4364 char_u **ptr, |
4364 int addr_type, /* flag: one of ADDR_LINES, ... */ | 4365 int addr_type, /* flag: one of ADDR_LINES, ... */ |
4365 int skip, /* only skip the address, don't use it */ | 4366 int skip, /* only skip the address, don't use it */ |
4366 int to_other_file) /* flag: may jump to other file */ | 4367 int to_other_file, /* flag: may jump to other file */ |
4368 int address_count) /* 1 for first address, >1 after comma */ | |
4367 { | 4369 { |
4368 int c; | 4370 int c; |
4369 int i; | 4371 int i; |
4370 long n; | 4372 long n; |
4371 char_u *cmd; | 4373 char_u *cmd; |
4637 n = getdigits(&cmd); | 4639 n = getdigits(&cmd); |
4638 if (addr_type == ADDR_LOADED_BUFFERS | 4640 if (addr_type == ADDR_LOADED_BUFFERS |
4639 || addr_type == ADDR_BUFFERS) | 4641 || addr_type == ADDR_BUFFERS) |
4640 lnum = compute_buffer_local_count( | 4642 lnum = compute_buffer_local_count( |
4641 addr_type, lnum, (i == '-') ? -1 * n : n); | 4643 addr_type, lnum, (i == '-') ? -1 * n : n); |
4642 else if (i == '-') | |
4643 lnum -= n; | |
4644 else | 4644 else |
4645 lnum += n; | 4645 { |
4646 #ifdef FEAT_FOLDING | |
4647 /* Relative line addressing, need to adjust for folded lines | |
4648 * now, but only do it after the first address. */ | |
4649 if (addr_type == ADDR_LINES && (i == '-' || i == '+') | |
4650 && address_count >= 2) | |
4651 (void)hasFolding(lnum, NULL, &lnum); | |
4652 #endif | |
4653 if (i == '-') | |
4654 lnum -= n; | |
4655 else | |
4656 lnum += n; | |
4657 } | |
4646 } | 4658 } |
4647 } while (*cmd == '/' || *cmd == '?'); | 4659 } while (*cmd == '/' || *cmd == '?'); |
4648 | 4660 |
4649 error: | 4661 error: |
4650 *ptr = cmd; | 4662 *ptr = cmd; |
9299 static void | 9311 static void |
9300 ex_copymove(exarg_T *eap) | 9312 ex_copymove(exarg_T *eap) |
9301 { | 9313 { |
9302 long n; | 9314 long n; |
9303 | 9315 |
9304 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE); | 9316 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, 1); |
9305 if (eap->arg == NULL) /* error detected */ | 9317 if (eap->arg == NULL) /* error detected */ |
9306 { | 9318 { |
9307 eap->nextcmd = NULL; | 9319 eap->nextcmd = NULL; |
9308 return; | 9320 return; |
9309 } | 9321 } |