Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into tabsidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtnn committed Jul 30, 2024
2 parents e673ce3 + 491e55d commit c91c6ab
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 48 deletions.
2 changes: 2 additions & 0 deletions .github/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ runtime/ftplugin/nim.vim @ribru17
runtime/ftplugin/nroff.vim @a-vrma
runtime/ftplugin/nsis.vim @k-takata
runtime/ftplugin/octave.vim @dkearns
runtime/ftplugin/ondir.vim @jparise
runtime/ftplugin/openvpn.vim @ObserverOfTime
runtime/ftplugin/pascal.vim @dkearns
runtime/ftplugin/pbtxt.vim @lakshayg
Expand Down Expand Up @@ -501,6 +502,7 @@ runtime/syntax/ninja.vim @nico
runtime/syntax/nix.vim @equill
runtime/syntax/nroff.vim @jmarshall
runtime/syntax/nsis.vim @k-takata
runtime/syntax/ondir.vim @jparise
runtime/syntax/openvpn.vim @ObserverOfTime
runtime/syntax/pacmanlog.vim @rpigott
runtime/syntax/pascal.vim @dkearns
Expand Down
16 changes: 13 additions & 3 deletions runtime/autoload/netrw.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" Maintainer: This runtime file is looking for a new maintainer.
" Date: May 03, 2023
" Version: 173a
" Last Change:
" Last Change: {{{1
" 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a)
" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a)
" 2024 Feb 19 by Vim Project: (announce adoption)
Expand All @@ -18,6 +18,8 @@
" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114)
" 2024 Jul 22 by Vim Project: avoid endless recursion (#15318)
" 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330)
" 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112)
" }}}
" Former Maintainer: Charles E Campbell
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
Expand Down Expand Up @@ -7165,7 +7167,7 @@ fun! s:NetrwMarkFileCopy(islocal,...)
endif

" copy marked files while within the same directory (ie. allow renaming)
if simplify(s:netrwmftgt) == simplify(b:netrw_curdir)
if s:StripTrailingSlash(simplify(s:netrwmftgt)) == s:StripTrailingSlash(simplify(b:netrw_curdir))
if len(s:netrwmarkfilelist_{bufnr('%')}) == 1
" only one marked file
" call Decho("case: only one marked file",'~'.expand("<slnum>"))
Expand Down Expand Up @@ -7242,7 +7244,7 @@ fun! s:NetrwMarkFileCopy(islocal,...)
" call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("<slnum>"))
call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'")
if v:shell_error != 0
if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir
if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && g:netrw_keepdir
call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",101)
else
call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localcopycmd<".g:netrw_localcopycmd.">; it doesn't work!",80)
Expand Down Expand Up @@ -11645,6 +11647,14 @@ fun! netrw#WinPath(path)
return path
endfun

" ---------------------------------------------------------------------
" s:StripTrailingSlash: removes trailing slashes from a path {{{2
fun! s:StripTrailingSlash(path)
" remove trailing slash
return substitute(a:path, '[/\\]$', '', 'g')
endfun


" ---------------------------------------------------------------------
" s:NetrwBadd: adds marked files to buffer list or vice versa {{{2
" cb : bl2mf=0 add marked files to buffer list
Expand Down
20 changes: 6 additions & 14 deletions runtime/autoload/zip.vim
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
" zip.vim: Handles browsing zipfiles
" AUTOLOAD PORTION
" Date: Jul 24, 2024
" Date: Jul 30, 2024
" Version: 33
" Maintainer: This runtime file is looking for a new maintainer.
" Former Maintainer: Charles E Campbell
" Last Change:
" 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998)
" 2024 Jul 23 by Vim Project: fix 'x' command
" 2024 Jul 24 by Vim Project: use delete() function
" 2024 Jul 20 by Vim Project: fix opening remote zipfile
" License: Vim License (see vim's :help license)
" Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
Expand Down Expand Up @@ -73,15 +74,11 @@ endif
" ---------------------------------------------------------------------
" zip#Browse: {{{2
fun! zip#Browse(zipfile)
" call Dfunc("zip#Browse(zipfile<".a:zipfile.">)")
" sanity check: insure that the zipfile has "PK" as its first two letters
" (zipped files have a leading PK as a "magic cookie")
if !filereadable(a:zipfile) || readfile(a:zipfile, "", 1)[0] !~ '^PK'
exe "noswapfile noautocmd noswapfile e ".fnameescape(a:zipfile)
" call Dret("zip#Browse : not a zipfile<".a:zipfile.">")
" sanity check: ensure that the zipfile has "PK" as its first two letters
" (zip files have a leading PK as a "magic cookie")
if filereadable(a:zipfile) && readblob(a:zipfile, 0, 2) != 0z50.4B
exe "noswapfile noautocmd e " .. fnameescape(a:zipfile)
return
" else " Decho
" call Decho("zip#Browse: a:zipfile<".a:zipfile."> passed PK test - it's a zip file")
endif

let repkeep= &report
Expand All @@ -97,23 +94,18 @@ fun! zip#Browse(zipfile)
if !executable(g:zip_unzipcmd)
redraw!
echohl Error | echo "***error*** (zip#Browse) unzip not available on your system"
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("zip#Browse")
return
endif
if !filereadable(a:zipfile)
if a:zipfile !~# '^\a\+://'
" if it's an url, don't complain, let url-handlers such as vim do its thing
redraw!
echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
endif
let &report= repkeep
" call Dret("zip#Browse : file<".a:zipfile."> not readable")
return
endif
" call Decho("passed sanity checks")
if &ma != 1
set ma
endif
Expand Down
6 changes: 5 additions & 1 deletion runtime/doc/syntax.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*syntax.txt* For Vim version 9.1. Last change: 2024 Jul 25
*syntax.txt* For Vim version 9.1. Last change: 2024 Jul 30


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -1908,6 +1908,10 @@ You can also disable this rendering by adding the following line to your
vimrc file: >
:let html_no_rendering=1
By default Vim synchronises the syntax to 250 lines before the first displayed
line. This can be configured using: >
:let html_minlines = 500
<
HTML comments are rather special (see an HTML reference document for the
details), and the syntax coloring scheme will highlight all errors.
However, if you prefer to use the wrong style (starts with <!-- and
Expand Down
4 changes: 3 additions & 1 deletion runtime/doc/version9.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*version9.txt* For Vim version 9.1. Last change: 2024 Jul 28
*version9.txt* For Vim version 9.1. Last change: 2024 Jul 30


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -41590,6 +41590,8 @@ Changed~
behaviour/inconsistency (see |d-special| and |cw|).
- allow to specify additional attributes in the completion menu (allows to
mark deprecated attributes from LSP server) |complete-items|
- the regex engines match correctly case-insensitive multi-byte characters
(and apply proper case folding)

*added-9.2*
Added ~
Expand Down
11 changes: 3 additions & 8 deletions runtime/ftplugin/cuda.vim
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
" Vim filetype plugin
" Language: CUDA
" Maintainer: Riley Bruins <[email protected]>
" Last Change: 2024 Jul 06
" Last Change: 2024 Jul 29

if exists('b:did_ftplugin')
finish
endif
let b:did_ftplugin = 1

" Set 'comments' to format dashed lists in comments.
" Also include ///, used for Doxygen.
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
setlocal commentstring=//\ %s

let b:undo_ftplugin = 'setl com< cms<'
" Behaves mostly just like C++
runtime! ftplugin/cpp.vim
3 changes: 2 additions & 1 deletion runtime/syntax/html.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
" Previous Maintainers: Jorge Maldonado Ventura <[email protected]>
" Claudio Fleiner <[email protected]>
" Last Change: 2023 Nov 28
" 2024 Jul 30 by Vim Project: increase syn-sync-minlines to 250

" See :help html.vim for some comments and a description of the options

Expand Down Expand Up @@ -320,7 +321,7 @@ if main_syntax == "html"
syn sync match htmlHighlight groupthere NONE "<[/a-zA-Z]"
syn sync match htmlHighlight groupthere javaScript "<script"
syn sync match htmlHighlightSkip "^.*['\"].*$"
syn sync minlines=10
exe "syn sync minlines=" . get(g:, 'html_minlines', 250)
endif

" Folding
Expand Down
11 changes: 7 additions & 4 deletions src/getchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,7 @@ handle_mapping(
int save_m_silent;
char_u *save_m_keys;
char_u *save_alt_m_keys;
int save_alt_m_keylen;
#else
# define save_m_noremap mp->m_noremap
# define save_m_silent mp->m_silent
Expand Down Expand Up @@ -3206,6 +3207,7 @@ handle_mapping(
save_m_silent = mp->m_silent;
save_m_keys = NULL; // only saved when needed
save_alt_m_keys = NULL; // only saved when needed
save_alt_m_keylen = mp->m_alt != NULL ? mp->m_alt->m_keylen : 0;

/*
* Handle ":map <expr>": evaluate the {rhs} as an expression. Also
Expand All @@ -3222,9 +3224,10 @@ handle_mapping(
vgetc_busy = 0;
may_garbage_collect = FALSE;

save_m_keys = vim_strsave(mp->m_keys);
save_m_keys = vim_strnsave(mp->m_keys, (size_t)mp->m_keylen);
save_alt_m_keys = mp->m_alt != NULL
? vim_strsave(mp->m_alt->m_keys) : NULL;
? vim_strnsave(mp->m_alt->m_keys,
(size_t)save_alt_m_keylen) : NULL;
map_str = eval_map_expr(mp, NUL);

// The mapping may do anything, but we expect it to take care of
Expand Down Expand Up @@ -3287,12 +3290,12 @@ handle_mapping(
&& STRNCMP(map_str, save_m_keys, (size_t)keylen) == 0)
|| (save_alt_m_keys != NULL
&& STRNCMP(map_str, save_alt_m_keys,
STRLEN(save_alt_m_keys)) == 0) :
(size_t)save_alt_m_keylen) == 0) :
#endif
STRNCMP(map_str, mp->m_keys, (size_t)keylen) == 0
|| (mp->m_alt != NULL
&& STRNCMP(map_str, mp->m_alt->m_keys,
STRLEN(mp->m_alt->m_keys)) == 0))
(size_t)mp->m_alt->m_keylen) == 0))
noremap = REMAP_SKIP;
else
noremap = REMAP_YES;
Expand Down
9 changes: 9 additions & 0 deletions src/mbyte.c
Original file line number Diff line number Diff line change
Expand Up @@ -3800,6 +3800,15 @@ utf_strnicmp(
* Returns zero if s1 and s2 are equal (ignoring case), the difference between
* two characters otherwise.
*/
int
mb_strnicmp2(char_u *s1, char_u *s2, size_t n1, size_t n2)
{
if (n1 == n2 || !enc_utf8)
return mb_strnicmp(s1, s2, n1);
else
return utf_strnicmp(s1, s2, n1, n2);
}

int
mb_strnicmp(char_u *s1, char_u *s2, size_t nn)
{
Expand Down
1 change: 1 addition & 0 deletions src/proto/mbyte.pro
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ int utf_islower(int a);
int utf_tolower(int a);
int utf_isupper(int a);
int mb_strnicmp(char_u *s1, char_u *s2, size_t nn);
int mb_strnicmp2(char_u *s1, char_u *s2, size_t n1, size_t n2);
void show_utf8(void);
int latin_head_off(char_u *base, char_u *p);
int dbcs_screen_head_off(char_u *base, char_u *p);
Expand Down
58 changes: 46 additions & 12 deletions src/regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,9 @@ mb_decompose(int c, int *c1, int *c2, int *c3)
/*
* Compare two strings, ignore case if rex.reg_ic set.
* Return 0 if strings match, non-zero otherwise.
* Correct the length "*n" when composing characters are ignored.
* Correct the length "*n" when composing characters are ignored
* or for utf8 when both utf codepoints are considered equal because of
* case-folding but have different length (e.g. 's' and 'ſ')
*/
static int
cstrncmp(char_u *s1, char_u *s2, int *n)
Expand All @@ -1738,6 +1740,29 @@ cstrncmp(char_u *s1, char_u *s2, int *n)

if (!rex.reg_ic)
result = STRNCMP(s1, s2, *n);
else if (enc_utf8)
{
char_u *p = s1;
size_t n2 = 0;
int n1 = *n;
// count the number of characters for byte-length of s1
while (n1 > 0 && *p != NUL)
{
n1 -= mb_ptr2len(s1);
MB_PTR_ADV(p);
n2++;
}
// count the number of bytes to advance the same number of chars for s2
p = s2;
while (n2-- > 0 && *p != NUL)
MB_PTR_ADV(p);

n2 = p - s2;

result = MB_STRNICMP2(s1, s2, *n, n2);
if (result == 0 && (int)n2 < *n)
*n = n2;
}
else
result = MB_STRNICMP(s1, s2, *n);

Expand Down Expand Up @@ -1787,7 +1812,7 @@ cstrncmp(char_u *s1, char_u *s2, int *n)
cstrchr(char_u *s, int c)
{
char_u *p;
int cc;
int cc, lc;

if (!rex.reg_ic || (!enc_utf8 && mb_char2len(c) > 1))
return vim_strchr(s, c);
Expand All @@ -1796,26 +1821,35 @@ cstrchr(char_u *s, int c)
// faster (esp. when using MS Visual C++!).
// For UTF-8 need to use folded case.
if (enc_utf8 && c > 0x80)
{
cc = utf_fold(c);
lc = cc;
}
else
if (MB_ISUPPER(c))
cc = MB_TOLOWER(c);
else if (MB_ISLOWER(c))
cc = MB_TOUPPER(c);
else
return vim_strchr(s, c);
if (MB_ISUPPER(c))
{
cc = MB_TOLOWER(c);
lc = cc;
}
else if (MB_ISLOWER(c))
{
cc = MB_TOUPPER(c);
lc = c;
}
else
return vim_strchr(s, c);

if (has_mbyte)
{
for (p = s; *p != NUL; p += (*mb_ptr2len)(p))
{
if (enc_utf8 && c > 0x80)
int uc = utf_ptr2char(p);
if (enc_utf8 && (c > 0x80 || uc > 0x80))
{
int uc = utf_ptr2char(p);

// Do not match an illegal byte. E.g. 0xff matches 0xc3 0xbf,
// not 0xff.
if ((uc < 0x80 || uc != *p) && utf_fold(uc) == cc)
// compare with lower case of the character
if ((uc < 0x80 || uc != *p) && utf_fold(uc) == lc)
return p;
}
else if (*p == c || *p == cc)
Expand Down
8 changes: 8 additions & 0 deletions src/regexp_bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3823,6 +3823,14 @@ regmatch(
}
}
}
else if (enc_utf8)
{
if (cstrncmp(opnd, rex.input, &len) != 0)
{
status = RA_NOMATCH;
break;
}
}
else
for (i = 0; i < len; ++i)
if (opnd[i] != rex.input[i])
Expand Down
9 changes: 7 additions & 2 deletions src/regexp_nfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -5666,7 +5666,12 @@ find_match_text(colnr_T *startcol, int regstart, char_u *match_text)
for (;;)
{
match = TRUE;
len2 = MB_CHAR2LEN(regstart); // skip regstart
// skip regstart
len2 = MB_CHAR2LEN(regstart);
if (enc_utf8 && len2 > 1 && MB_CHAR2LEN(PTR2CHAR(rex.line + col)) != len2)
// because of case-folding of the previously matched text, we may need
// to skip fewer bytes than mb_char2len(regstart)
len2 = mb_char2len(utf_fold(regstart));
for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1))
{
c1 = PTR2CHAR(match_text + len1);
Expand Down Expand Up @@ -7502,7 +7507,7 @@ nfa_regexec_both(

// If match_text is set it contains the full text that must match.
// Nothing else to try. Doesn't handle combining chars well.
if (prog->match_text != NULL && !rex.reg_icombine)
if (prog->match_text != NULL && *prog->match_text != NUL && !rex.reg_icombine)
{
retval = find_match_text(&col, prog->regstart, prog->match_text);
if (REG_MULTI)
Expand Down
Loading

0 comments on commit c91c6ab

Please sign in to comment.