Compare commits

...

8 Commits

Author SHA1 Message Date
Lewis Russell 0c46a1598b
Merge a4f65b5435 into 435dee74bb 2024-04-26 19:48:27 -04:00
zeertzjq 435dee74bb
vim-patch:9.1.0374: wrong botline in BufEnter (#28530)
Problem:  When :edit an existing buffer, line('w$') may return a
          wrong result.
Solution: Reset w_valid in curwin_init() (Jaehwang Jung)

`do_ecmd()` reinitializes the current window (`curwin_init()`) whose
`w_valid` field may have `VALID_BOTLINE` set. Resetting `w_botline`
without marking it as invalid makes subsequent `validate_botline()`
calls a no-op, thus resulting in wrong `line('w$')` value.

closes: vim/vim#14642

eb80b8304e

Co-authored-by: Jaehwang Jung <tomtomjhj@gmail.com>
2024-04-27 06:32:25 +08:00
zeertzjq 694756252b
Merge pull request #28529 from zeertzjq/vim-fe1e2b5e2d65
vim-patch: clarify syntax vs matching mechanism
2024-04-27 06:31:55 +08:00
zeertzjq e81eb34aa1 vim-patch:9525f6213604
runtime(doc): fix typo synconcealend -> synconcealed (vim/vim#14644)

9525f62136

Co-authored-by: Philip H <47042125+pheiduck@users.noreply.github.com>
2024-04-27 05:52:47 +08:00
zeertzjq a1568f5df0 vim-patch:00ae5c5cba7b
runtime(doc): fix typo

00ae5c5cba

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-04-27 05:52:15 +08:00
zeertzjq f1f5fb911b vim-patch:fe1e2b5e2d65
runtime(doc): clarify syntax vs matching mechanism

fixes: vim/vim#14643

fe1e2b5e2d

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-04-27 05:51:52 +08:00
Lewis Russell a4f65b5435 feat(normal)!: remove the default g? normal mode command
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-04-25 12:23:56 +01:00
Lewis Russell 72bae3d2b7 feat(normal)!: remove the default gs normal mode command
Problem:

gs is a stupid normal command.

Solution:

Remove it!
2024-04-24 15:39:29 +01:00
22 changed files with 63 additions and 64 deletions

View File

@ -8208,6 +8208,10 @@ synconcealed({lnum}, {col}) *synconcealed()*
synconcealed(lnum, 5) [1, 'X', 2]
synconcealed(lnum, 6) [0, '', 0]
Note: Doesn't consider |matchadd()| highlighting items,
since syntax and matching highlighting are two different
mechanisms |syntax-vs-match|.
synstack({lnum}, {col}) *synstack()*
Return a |List|, which is the stack of syntax items at the
position {lnum} and {col} in the current window. {lnum} is

View File

@ -337,16 +337,6 @@ gu{motion} Make {motion} text lowercase.
gugu *gugu* *guu*
guu Make current line lowercase.
*g?* *rot13*
g?{motion} Rot13 encode {motion} text.
*v_g?*
{Visual}g? Rot13 encode the highlighted text (for {Visual} see
|Visual-mode|).
g?g? *g?g?* *g??*
g?? Rot13 encode current line.
To turn one line into title caps, make every first letter of a word
uppercase: >
:s/\v<(.)(\w*)/\u\1\L\2/g

View File

@ -722,9 +722,6 @@ tag char note action in Normal mode ~
character under the cursor
|g;| g; 1 go to N older position in change list
|g<| g< display previous command output
|g?| g? 2 Rot13 encoding operator
|g?g?| g?? 2 Rot13 encode current line
|g?g?| g?g? 2 Rot13 encode current line
|gD| gD 1 go to definition of word under the cursor
in current file
|gE| gE 1 go backwards to the end of the previous

View File

@ -47,7 +47,6 @@ or change text. The following operators are available:
|=| = filter through 'equalprg' or C-indenting if empty
|gq| gq text formatting
|gw| gw text formatting with no cursor movement
|g?| g? ROT13 encoding
|>| > shift right
|<| < shift left
|zf| zf define a fold

View File

@ -140,6 +140,10 @@ The following changes may require adaptations in user config or plugins.
• |nvim_open_win()| now blocks all autocommands when `noautocmd` is set,
rather than just those from setting the `buffer` to display in the window.
• Removed the |gs| normal command.
• Removed the |g?| normal command.
==============================================================================
BREAKING CHANGES IN HEAD *news-breaking-dev*

View File

@ -1375,6 +1375,19 @@ Finally, these constructs are unique to Perl:
==============================================================================
10. Highlighting matches *match-highlight*
*syntax-vs-match*
Note that the match highlight mechanism is independent
of |syntax-highlighting|, which is (usually) a buffer-local
highlighting, while matching is window-local, both methods
can be freely mixed. Match highlighting functions give you
a bit more flexibility in when and how to apply, but are
typically only used for temporary highlighting, without strict
rules. Both methods can be used to conceal text.
Thus the matching functions like |matchadd()| won't consider
syntax rules and functions like |synconcealed()| and the
other way around.
*:mat* *:match*
:mat[ch] {group} /{pattern}/
Define a pattern to highlight in the current window. It will

View File

@ -413,10 +413,6 @@ In Insert or Command-line mode:
lowercase
|gU| gU{motion} make the text that is moved over with {motion}
uppercase
|v_g?| {visual}g? perform rot13 encoding on highlighted text
|g?| g?{motion} perform rot13 encoding on the text that is moved over
with {motion}
|CTRL-A| N CTRL-A add N to the number at or after the cursor
|CTRL-X| N CTRL-X subtract N from the number at or after the cursor

View File

@ -3825,7 +3825,9 @@ Whether or not it is actually concealed depends on the value of the
'conceallevel' option. The 'concealcursor' option is used to decide whether
concealable items in the current line are displayed unconcealed to be able to
edit the line.
Another way to conceal text is with |matchadd()|.
Another way to conceal text is with |matchadd()|, but internally this works a
bit differently |syntax-vs-match|.
concealends *:syn-concealends*
@ -3833,7 +3835,9 @@ When the "concealends" argument is given, the start and end matches of
the region, but not the contents of the region, are marked as concealable.
Whether or not they are actually concealed depends on the setting on the
'conceallevel' option. The ends of a region can only be concealed separately
in this way when they have their own highlighting via "matchgroup"
in this way when they have their own highlighting via "matchgroup". The
|synconcealed()| function can be used to retrieve information about conealed
items.
cchar *:syn-cchar*
*E844*

View File

@ -948,7 +948,7 @@ Syntax and highlighting: *syntax-functions* *highlighting-functions*
synIDattr() get a specific attribute of a syntax ID
synIDtrans() get translated syntax ID
synstack() get list of syntax IDs at a specific position
synconcealed() get info about concealing
synconcealed() get info about (syntax) concealing
diff_hlID() get highlight ID for diff mode at a position
matchadd() define a pattern to highlight (a "match")
matchaddpos() define a list of positions to highlight

View File

@ -515,16 +515,15 @@ gO Show a filetype-specific, navigable "outline" of the
Currently works in |help| and |:Man| buffers.
[N]gs *gs* *:sl* *:sleep*
*:sl* *:sleep*
:[N]sl[eep] [N][m] Do nothing for [N] seconds, or [N] milliseconds if [m]
was given. "gs" always uses seconds.
was given.
Default is one second. >
:sleep "sleep for one second
:5sleep "sleep for five seconds
:sleep 100m "sleep for 100 milliseconds
10gs "sleep for ten seconds
< Can be interrupted with CTRL-C.
"gs" stands for "goto sleep".
While sleeping the cursor is positioned in the text,
if at a visible position.
Queued messages are processed during the sleep.

View File

@ -682,6 +682,9 @@ Highlight groups:
\|setlocal winhighlight=StatusLine:StatusLineTerm,StatusLineNC:StatusLineTermNC
\|else|setlocal winhighlight=|endif
<
Normal commands:
*gs*
*g?* *g??* *g?g?* *v_g?*
Options:
*'aleph'* *'al'*

View File

@ -9752,6 +9752,10 @@ function vim.fn.synIDtrans(synID) end
--- synconcealed(lnum, 5) [1, 'X', 2]
--- synconcealed(lnum, 6) [0, '', 0]
---
--- Note: Doesn't consider |matchadd()| highlighting items,
--- since syntax and matching highlighting are two different
--- mechanisms |syntax-vs-match|.
---
--- @param lnum integer
--- @param col integer
--- @return {[1]: integer, [2]: string, [3]: integer}

View File

@ -12,7 +12,6 @@
: (uint8_t)(x) - 'a')
#define CHAR_ORD_LOW(x) ((uint8_t)(x) - 'a')
#define CHAR_ORD_UP(x) ((uint8_t)(x) - 'A')
#define ROT13(c, a) (((((c) - (a)) + 13) % 26) + (a))
#define NUL '\000'
#define BELL '\007'

View File

@ -47,8 +47,8 @@ typedef struct {
#define VALID_VIRTCOL 0x04 // w_virtcol (file col) is valid
#define VALID_CHEIGHT 0x08 // w_cline_height and w_cline_folded valid
#define VALID_CROW 0x10 // w_cline_row is valid
#define VALID_BOTLINE 0x20 // w_botine and w_empty_rows are valid
#define VALID_BOTLINE_AP 0x40 // w_botine is approximated
#define VALID_BOTLINE 0x20 // w_botline and w_empty_rows are valid
#define VALID_BOTLINE_AP 0x40 // w_botline is approximated
#define VALID_TOPLINE 0x80 // w_topline is valid (for cursor position)
// flags for b_flags

View File

@ -11621,6 +11621,10 @@ M.funcs = {
synconcealed(lnum, 4) [1, 'X', 2]
synconcealed(lnum, 5) [1, 'X', 2]
synconcealed(lnum, 6) [0, '', 0]
Note: Doesn't consider |matchadd()| highlighting items,
since syntax and matching highlighting are two different
mechanisms |syntax-vs-match|.
]=],
name = 'synconcealed',
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },

View File

@ -3921,14 +3921,6 @@ static void nv_search(cmdarg_T *cap)
oparg_T *oap = cap->oap;
pos_T save_cursor = curwin->w_cursor;
if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13) {
// Translate "g??" to "g?g?"
cap->cmdchar = 'g';
cap->nchar = '?';
nv_operator(cap);
return;
}
// When using 'incsearch' the cursor may be moved to set a different search
// start position.
cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, true);
@ -5525,11 +5517,6 @@ static void nv_g_cmd(cmdarg_T *cap)
nv_gomark(cap);
break;
// "gs": Goto sleep.
case 's':
do_sleep(cap->count1 * 1000);
break;
// "ga": Display the ascii value of the character under the
// cursor. It is displayed in decimal, hex, and octal. -- webb
case 'a':
@ -5564,7 +5551,6 @@ static void nv_g_cmd(cmdarg_T *cap)
// "g~" Toggle the case of the text.
// "gu" Change text to lower case.
// "gU" Change text to upper case.
// "g?" rot13 encoding
// "g@" call 'operatorfunc'
case 'q':
case 'w':
@ -5573,7 +5559,6 @@ static void nv_g_cmd(cmdarg_T *cap)
case '~':
case 'u':
case 'U':
case '?':
case '@':
nv_operator(cap);
break;

View File

@ -114,7 +114,6 @@ static char opchars[][3] = {
{ 'g', 'u', OPF_CHANGE }, // OP_LOWER
{ 'J', NUL, OPF_LINES | OPF_CHANGE }, // DO_JOIN
{ 'g', 'J', OPF_LINES | OPF_CHANGE }, // DO_JOIN_NS
{ 'g', '?', OPF_CHANGE }, // OP_ROT13
{ 'r', NUL, OPF_CHANGE }, // OP_REPLACE
{ 'I', NUL, OPF_CHANGE }, // OP_INSERT
{ 'A', NUL, OPF_CHANGE }, // OP_APPEND
@ -2131,7 +2130,6 @@ static int swapchars(int op_type, pos_T *pos, int length)
/// @param op_type
/// == OP_UPPER: make uppercase,
/// == OP_LOWER: make lowercase,
/// == OP_ROT13: do rot13 encoding,
/// else swap case of character at 'pos'
///
/// @return true when something actually changed.
@ -2140,11 +2138,6 @@ bool swapchar(int op_type, pos_T *pos)
{
const int c = gchar_pos(pos);
// Only do rot13 encoding for ASCII characters.
if (c >= 0x80 && op_type == OP_ROT13) {
return false;
}
// ~ is OP_NOP, g~ is OP_TILDE, gU is OP_UPPER
if ((op_type == OP_UPPER || op_type == OP_NOP || op_type == OP_TILDE) && c == 0xdf) {
pos_T sp = curwin->w_cursor;
@ -2158,18 +2151,10 @@ bool swapchar(int op_type, pos_T *pos)
}
int nc = c;
if (mb_islower(c)) {
if (op_type == OP_ROT13) {
nc = ROT13(c, 'a');
} else if (op_type != OP_LOWER) {
nc = mb_toupper(c);
}
} else if (mb_isupper(c)) {
if (op_type == OP_ROT13) {
nc = ROT13(c, 'A');
} else if (op_type != OP_UPPER) {
nc = mb_tolower(c);
}
if (mb_islower(c) && op_type != OP_LOWER) {
nc = mb_toupper(c);
} else if (mb_isupper(c) && op_type != OP_UPPER) {
nc = mb_tolower(c);
}
if (nc != c) {
if (c >= 0x80 || nc >= 0x80) {
@ -6211,7 +6196,6 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_TILDE:
case OP_UPPER:
case OP_LOWER:
case OP_ROT13:
if (empty_region_error) {
vim_beep(BO_OPER);
CancelRedo();

View File

@ -80,7 +80,7 @@ enum {
OP_LOWER = 12, ///< "gu" make lower case operator
OP_JOIN = 13, ///< "J" join operator, only for Visual mode
OP_JOIN_NS = 14, ///< "gJ" join operator, only for Visual mode
OP_ROT13 = 15, ///< "g?" rot-13 encoding
// UNUSED = 15, ///< Previously used by OP_ROT13
OP_REPLACE = 16, ///< "r" replace chars, only for Visual mode
OP_INSERT = 17, ///< "I" Insert column, only for Visual mode
OP_APPEND = 18, ///< "A" Append column, only for Visual mode

View File

@ -2467,6 +2467,7 @@ void win_init_empty(win_T *wp)
wp->w_topline = 1;
wp->w_topfill = 0;
wp->w_botline = 2;
wp->w_valid = 0;
wp->w_s = &wp->w_buffer->b_s;
}

View File

@ -4105,4 +4105,16 @@ func Test_SwapExists_set_other_buf_modified()
bwipe!
endfunc
func Test_BufEnter_botline()
set hidden
call writefile(range(10), 'Xxx1', 'D')
call writefile(range(20), 'Xxx2', 'D')
edit Xxx1
edit Xxx2
au BufEnter Xxx1 call assert_true(line('w$') > 1)
edit Xxx1
au! BufEnter Xxx1
set hidden&vim
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -1908,6 +1908,7 @@ endfunc
func Test_normal24_rot13()
" Testing for g?? g?g?
throw 'Skipped: Nvim has removed g?'
new
call append(0, 'abcdefghijklmnopqrstuvwxyzäüö')
1

View File

@ -21,7 +21,7 @@ func! Test_sleep_bang()
call s:assert_takes_longer('sl 50m', 50)
call s:assert_takes_longer('sl! 50m', 50)
call s:assert_takes_longer('1sleep', 1000)
call s:assert_takes_longer('normal 1gs', 1000)
" call s:assert_takes_longer('normal 1gs', 1000)
endfunc
" vim: shiftwidth=2 sts=2 expandtab