Compare commits

...

11 Commits

Author SHA1 Message Date
Yegappan Lakshmanan
c1d77520b8 patch 9.1.2002: Vim9: heap-use-after-free when when accessing protect class member
Problem:  Vim9: heap-use-after-free when when accessing protect class
          member (Foxe Chen)
Solution: Set cl->class_type_list and return directly, add tests for
          using protected class method and variable from another class
          (Yegappan Lakshmanan).

closes: #18971

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-21 19:03:31 +00:00
Mao-Yining
8de7fd0c20 refactor(vim9): use 'start' open urls on win32
- Use `:!start` directly, discard the using of `explorer.exe`.
- Update the document in `eval.txt`.

closes: #18985

Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-21 18:59:48 +00:00
Mao-Yining
3255b8a556 runtime(vim9): Reset pwsh and powershell in Open()
relates: #17995
closes:  #18986

Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-21 18:45:26 +00:00
gagik
d57b4a3681 translation(hy): Update Armenian language translation
closes: #18990

Signed-off-by: gagik <hakgagik@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-21 18:42:18 +00:00
Mateo Gjika
83fd754150 runtime(openPlugin): start :Launch process in the background in GUI mode
fixes:  #18977
closes: #18981

Signed-off-by: Mateo Gjika <104777599+mateoxh@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-21 09:47:38 +00:00
Mao-Yining
2387c49f6e translation(zh_CN): Add license disclaimer
Added disclaimer to clarify that the Chinese translation is for
reference only and is not legally binding. The original English version
of the license is the sole authoritative text. No liability is accepted
for any ambiguities or errors arising from the translation.

closes: #18980

Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-20 18:29:16 +00:00
Muraoka Taro
6ec7d40b7c runtime(getscript): GLVS plugin fails with wget.exe with PowerShell
Problem:  Only Windows: The GLVS plugin fails in a PowerShell Desktop if
          wget.exe is installed. The PowerShell Desktop has an alias
          called wget which hides wget.exe.
Solution: Force .exe extension if wget.exe is available.

closes: #18987

Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-20 18:13:18 +00:00
Doug Kearns
a820a4540d runtime(doc): Fix "Vim script" formatting at :help clipboard-providers
closes: #18966

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-20 17:39:32 +00:00
glepnir
b43f9ded7e patch 9.1.2001: cursor may end up in wrong window after :botright copen
Problem:  After :botright copen and closing the quikfix window, the
          cursor ends up in the wrong window. The problem is fr_child
          always points to the first (leftmost for FR_ROW, topmost for
          FR_COL) child frame. When do :vsplit, the new window is
          created on the left, and frame_insert() updates the parent's
          fr_child to point to this new left window.
Solution: Create a snapshot before open the quickfix window and restore
          it when close it (glepnir).

closes: #18961

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-20 17:26:39 +00:00
Christian Brabandt
64799a5080 runtime(doc): clarify the behavior of CTRL-Z
fixes: #18975

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-20 16:54:07 +00:00
zoumi
1a4a1b9fa6 runtime(zip): Use :lcd instead of :cd in zip.vim
closes: #18967

Signed-off-by: zoumi <zoumi@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-20 16:25:16 +00:00
15 changed files with 486 additions and 240 deletions

View File

@@ -1,52 +1,60 @@
VIM 使用许可协议
注意: 本译文仅供参考。若因译文错漏引发任何问题译者概不承担责任。VIM 许可证的
完整英文版本为唯一法律依据。如有任何疑问,以英文原文为准。
I) 任何人均可不受限制地分发未经修改的 Vim 软件完整副本,但须在该等副本中包含本
许可协议全文。您亦可分发未经修改的 Vim 软件组成部分,该等分发行为同样不受限
制,惟仍须包含本许可协议全文。您还可随附基于未经修改的 Vim 源代码编译而成的
可执行文件、您自行编写的使用范例以及 Vim 脚本文件。
VIM 许可证
II) 在同时满足下列四项条件的前提下,(或扩展)的 Vim 软件版本(包括可执行文件、
源代码或二者兼具):
1) 必须完整包含未经任何改动的本许可协议文本
2) 经修改的 Vim 软件必须通过以下五种方式之一进行分发:
a) 如您对 Vim 软件自行实施修改,必须在分发材料中明确标注有效的联系方式。
当 Vim 维护者以任何形式向您索要您所分发的修改版副本时,您必须无偿向该
维护者提供全部修改内容(含源代码)。维护者保留将您的修改成果纳入 Vim
官方版本的权利。维护者将如何处置您的修改成果以及该等成果遵循何种许可协
议进行分发,均属可协商事项。若双方未达成特别约定,则您的修改内容自动适
用本协议或其后续版本。当前维护团队名单载于https://github.com/orgs/vim/people。
若前述信息发生变更,将通过适当渠道(通常为 vim.sf.net、www.vim.org 及/
或 comp.editors予以公告。当客观上完全无法联系到维护者时您向其提交
修改成果的义务即告终止。维护者确认收到修改成果后,您无需重复提交。
b) 如您获得依据本条第 a) 款方式分发的修改版 Vim可依照 I) 之规定继续分发
其未经改动的版本。若您在该版本基础上实施新的修改,则 a) 款相关规定对该
等新增修改同样适用。
c) 在您分发的每一份修改版 Vim 副本中,均需提供所有修改内容,包括源代码。
可采取上下文差异补丁等形式提供。您可自主选择适用于新增代码的许可协议。
该等修改内容及其所附许可协议不得限制其他使用者对 Vim 官方版本进行自主
修改。
d) 若您持有的修改版 Vim 包含符合本条第 c) 款特征的修改内容,在同时满足下
列三项条件时,可不提供修改部分的源代码进行分发:
- 适用于该修改内容的许可协议明确允许您无偿且无限制地向 Vim 维护者分发
该修改,并允许维护者无偿且无限制地将其纳入 Vim 官方版本;
- 您需自最后一次分发对应修改版 Vim 之日起,将修改内容至少保存三年。在
此期间,若维护者或任何从您处获得该修改版的人员向您索要修改内容,您必
须及时提供;
- 您必须在分发材料中明确标注有效的联系方式。该联系方式自最后一次分发对
应的修改版 Vim 后至少三年内保持有效,并应尽可能长期维持。
e) 若 GNU 通用公共许可证GPL适用于修改内容您可依据 GNU GPL 第二版或
其任何后续版本的规定分发修改后的 Vim 软件。
3) 必须至少在 ":version" 命令输出界面及软件启动画面中添加显著声明,以确保修
改版 Vim 的用户能够知悉该软件已被修改。依据本条第 2 款 e) 项规定进行分发
时,仅在所添加声明不与修改内容所适用许可协议相冲突的前提下,方须履行此项
声明添加义务。
4) 本条第 2 款 a) 项与 d) 项要求的联系方式不得被删除或篡改,但联系人本人可对
其进行修正更新。
I) 可以任意发布没有修改的 Vim 的拷贝,但是必须保证包含本许可证。您也可以发布
未经修改的部分 Vim同样也必须包含这份许可证。发布由未经修改的 Vim 源代码
所编译出的 Vim 可执行文件,外加您自己的应用实例和 Vim 脚本也是允许的
III) 如果您分发修改版的 Vim采用本协议作为其修改内容的许可依据并将其包括源
代码)提供给维护者。首选方式是通过电子邮件或将文件上传至服务器并通过电子邮
件发送 URL 地址。如果修改量较小(例如,修改过的 Makefile通过电子邮件发
送上下文差异补丁即可。应使用的电子邮件地址为 <maintainer@vim.org>。
II) 在满足以下全部四个条件的前提下,您可以发布经过修改 (或扩充) 的 Vim 版本,
包括可执行文件 和/或 源代码:
1) 本许可证必须包含在内,并且不能被修改。
2) 经过修改的 Vim 必须以下述五种方式之一发布:
a) 如果您本人对 Vim 做了改动,您必须在发布版本里清楚地说明如何与您联系。
当 Vim 的维护者 (以任何方式) 向您索取您所发布的 Vim 时,您必须把所做
的改动包括源代码无偿地提供出来。维护者保留把这些改动加入 Vim 正式版本
的权利。至于维护者怎样处理这些改动,以及用什么许可证发布,可以协商。
如果没有协商,那么,本许可证,或者它更新的版本,同样适用于您做出的改
动。Vim 现在的几位维护者可见:
https://github.com/orgs/vim/people
如果维护者发生变动,会在合适的地方 (很可能是 vim.sf.net、www.vim.org
和/或 comp.editors) 公布,当完全不能与维护者联系时,发送变更的约定自
动终止。一旦维护者确认收到了您所做的修改,您就不必再次发送了。
IV) 严禁从 Vim 源代码及其组成部分或任何修改版本的分发材料中移除本许可协议。您有
权选择将本协议适用于既往发布的 Vim 版本,以替代其原始随附的许可协议。
b) 如果您得到的是一个修改过的 Vim并且它是在条件 a) 下发布的,那么您可
以不加改动地在条件 I) 下发布它;如果您又做了额外的改动,则这些改动受
到 a) 款条文的约束。
c) 在您发布的经过修改的 Vim 的每一份拷贝里,提供所有的变更部分,包括源代
码。提供的形式可以采用上下文风格的差异比较记录 (context diff)。您可以
为添加的新代码选择许可证,但是这些更改和为其选择的许可证不能限制他人
对 Vim 正式版本作出自己的改动。
d) 在满足以下全部三个条件的前提下,您可以继续发布带有条件 c) 所提及之变
更的经过修改的 Vim而不必在发布时提供更改部分的源代码:
- 这些变更所附带的许可证允许您把这些变更无偿地并且没有任何限制地提供
给 Vim 的维护者,而且允许 Vim 的维护者无偿地并且没有任何限制地把这
些更改加入到 Vim 的正式版本中。
- 从您最后一次发布更改的 Vim 之日起,您要保存这些改动至少三年时间。在
这期间,维护者或别人 (以任何方式) 向您要求提供这些变更时,您必须提
供给他。
- 您要在发布版本中清楚地说明如何与您联系,这个联系方式必须保证自最后
一次发布相应的经过修改的 Vim 之日起至少三年有效,或尽可能长。
e) 当这些变更以 GPL (GNU General Public LicenseGNU 通用公共许可证) 发
布时,您可以在 GPL 版本 2或更高版本的 GPL 下发布修改过的 Vim。
3) 必须添加一条改动的信息。至少要放在 "version" 命令的输出和启动画面里,好
让用户知道自己用的是一个修改过的 Vim。当以 2)e) 条件发布时,只有不与变
更适用的许可证冲突,这个信息的添加才是必要的。
4) 在 2)a) 和 2)d) 条件里要求的联系方式不能随便更改或删除,除非是作者自己
作出的更正。
III) 如果您发布一个更改过的 Vim强烈建议您对变更部分使用 Vim 的许可证,并且对
维护者提供变更部分并开放源代码。最好的方式是通过电子邮件或者把文件放到服
务器上,通过电子邮件传送 URL。如果只修改了很少的部分 (例如,只是一个修改
过的 Makefile),那么传送一个上下文风格的差异比较记录 (context diff) 就可
以了。电子邮件的地址是 <maintainer@vim.org>
IV) 不允许从 Vim 的源代码的发行版本或其中部分的源代码里删除本许可证,即使来自
更改过的版本也是如此。您可能想用这份许可证代替以前版本的 Vim 里的许可证,
这可以由您自行决定。

View File

@@ -3,7 +3,7 @@ vim9script
# Vim runtime support library
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
# Last Change: 2025 Aug 15
# Last Change: 2025 Dec 21
export def IsSafeExecutable(filetype: string, executable: string): bool
if empty(exepath(executable))
@@ -60,15 +60,19 @@ if has('unix')
enddef
else
export def Launch(args: string)
const fork = has('gui_running') ? '' : '&'
const fork = has('gui_running') ? '&' : ''
execute $':silent ! nohup {args} {Redir()} {fork}' | redraw!
enddef
endif
elseif has('win32')
export def Launch(args: string)
const shell = (&shell =~? '\<cmd\.exe\>') ? '' : 'cmd.exe /c'
const quotes = empty(shell) ? '' : '""'
execute $'silent ! {shell} start {quotes} /b {args} {Redir()}' | redraw!
try
execute ':silent !start' args | redraw!
catch /^Vim(!):E371:/
echohl ErrorMsg
echom "dist#vim9#Launch(): can not start" args
echohl None
endtry
enddef
else
export def Launch(dummy: string)
@@ -81,7 +85,10 @@ var os_viewer = null_string
if has('win32unix')
# (cyg)start suffices
os_viewer = ''
# Windows / WSL
# Windows
elseif has('win32')
os_viewer = '' # Use :!start
# WSL
elseif executable('explorer.exe')
os_viewer = 'explorer.exe'
# Linux / BSD
@@ -126,6 +133,11 @@ export def Open(file: string)
&shellslash = false
defer setbufvar('%', '&shellslash', true)
endif
if &shell == 'pwsh' || &shell == 'powershell'
const shell = &shell
setlocal shell&
defer setbufvar('%', '&shell', shell)
endif
Launch($"{Viewer()} {shellescape(file, 1)}")
enddef

View File

@@ -14,6 +14,7 @@
" 2024 Nov 12 by Vim Project: fix problems on Windows (#16036)
" 2025 Feb 28 by Vim Project: add support for bzip3 (#16755)
" 2025 May 11 by Vim Project: check network connectivity (#17249)
" 2025 Dec 21 by Vim Project: make the wget check more robust (#18987)
" }}}
"
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
@@ -58,7 +59,10 @@ endif
" wget vs curl {{{2
if !exists("g:GetLatestVimScripts_wget")
if executable("wget")
if executable("wget.exe")
" enforce extension: windows powershell desktop version has a wget alias that hides wget.exe
let g:GetLatestVimScripts_wget= "wget.exe"
elseif executable("wget")
let g:GetLatestVimScripts_wget= "wget"
elseif executable("curl.exe")
" enforce extension: windows powershell desktop version has a curl alias that hides curl.exe
@@ -73,7 +77,7 @@ endif
" options that wget and curl require:
if !exists("g:GetLatestVimScripts_options")
if g:GetLatestVimScripts_wget == "wget"
if g:GetLatestVimScripts_wget =~ "wget"
let g:GetLatestVimScripts_options= "-q -O"
elseif g:GetLatestVimScripts_wget =~ "curl"
let g:GetLatestVimScripts_options= "-s -o"

View File

@@ -17,6 +17,7 @@
" 2025 Mar 11 by Vim Project: handle filenames with leading '-' correctly
" 2025 Jul 12 by Vim Project: drop ../ on write to prevent path traversal attacks
" 2025 Sep 22 by Vim Project: support PowerShell Core
" 2025 Dec 20 by Vim Project: use :lcd instead of :cd
" 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,
@@ -371,7 +372,7 @@ fun! zip#Write(fname)
call mkdir(tmpdir,"p")
" attempt to change to the indicated directory
if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory")
if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot lcd to temporary directory")
return
endif
@@ -380,7 +381,7 @@ fun! zip#Write(fname)
call delete("_ZIPVIM_", "rf")
endif
call mkdir("_ZIPVIM_")
cd _ZIPVIM_
lcd _ZIPVIM_
if has("unix")
let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','')
@@ -455,7 +456,7 @@ fun! zip#Write(fname)
endif
" cleanup and restore current directory
cd ..
lcd ..
call delete("_ZIPVIM_", "rf")
call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!")
call delete(tmpdir, "rf")
@@ -536,7 +537,7 @@ endfun
" s:ChgDir: {{{2
fun! s:ChgDir(newdir,errlvl,errmsg)
try
exe "cd ".fnameescape(a:newdir)
exe "lcd ".fnameescape(a:newdir)
catch /^Vim\%((\a\+)\)\=:E344/
redraw!
if a:errlvl == s:NOTE

View File

@@ -1,4 +1,4 @@
*eval.txt* For Vim version 9.1. Last change: 2025 Dec 18
*eval.txt* For Vim version 9.1. Last change: 2025 Dec 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -5231,7 +5231,7 @@ $VIMRUNTIME/plugin/openPlugin.vim
dist#vim9#Open(file: string) ~
Opens `path` with the system default handler (macOS `open`, Windows
`explorer.exe`, Linux `xdg-open`, …). If the variable |g:Openprg| exists the
`start`, Linux `xdg-open`, …). If the variable |g:Openprg| exists the
string specified in the variable is used instead.
The |:Open| user command uses file completion for its argument.
@@ -5284,7 +5284,7 @@ Usage: >vim
15. Clipboard providers *clipboard-providers*
The clipboard provider feature allows the "+" |quoteplus| and "*" |quotestar|
registers to be overridden by custom Vimscript functions. There can be
registers to be overridden by custom Vim script functions. There can be
multiple providers, and Vim chooses which one to use based on 'clipmethod'.
Despite the name, it should be treated separate from the clipboard
@@ -5295,7 +5295,7 @@ clipboard registers.
The clipboard provider feature will respect the "unnamed" and "unnamedplus"
values in the 'clipboard' option. Any other value will be ignored.
*clipboard-providers-no-clipboard*
*clipboard-providers-no-clipboard*
If the |+clipboard| feature is not enabled, then the "+" and "*" registers
will not be enabled/available unless |v:clipmethod| is set to a provider. If
it is set to a provider, then the clipboard registers will be exposed despite

View File

@@ -1,4 +1,4 @@
*starting.txt* For Vim version 9.1. Last change: 2025 Nov 09
*starting.txt* For Vim version 9.1. Last change: 2025 Dec 20
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1287,7 +1287,7 @@ CTRL-Z Suspend Vim, like ":stop".
Works in Normal and in Visual mode. In Insert and
Command-line mode, the CTRL-Z is inserted as a normal
character. In Visual mode Vim goes back to Normal
mode.
mode before suspending.
Note: if CTRL-Z undoes a change see |mswin.vim|.

File diff suppressed because it is too large Load Diff

View File

@@ -4612,6 +4612,12 @@ qf_open_new_cwindow(qf_info_T *qi, int height)
if (cmdmod.cmod_split == 0)
flags = WSP_BELOW;
flags |= WSP_NEWLOC;
// Create a snapshot for quickfix window (not for location list)
// so that when closing it, we can restore to the previous window
if (IS_QF_STACK(qi))
flags |= WSP_QUICKFIX;
if (win_split(height, flags) == FAIL)
return FAIL; // not enough room for window
RESET_BINDING(curwin);

View File

@@ -3693,9 +3693,10 @@ typedef void diffline_T;
typedef void diffline_change_T;
#endif
#define SNAP_HELP_IDX 0
#define SNAP_AUCMD_IDX 1
#define SNAP_COUNT 2
#define SNAP_HELP_IDX 0
#define SNAP_AUCMD_IDX 1
#define SNAP_QUICKFIX_IDX 2
#define SNAP_COUNT 3
/*
* Tab pages point to the top frame of each tab page.

View File

@@ -6958,4 +6958,15 @@ func Test_vimgrep_dummy_buffer_keep()
%bw!
endfunc
func Test_quickfix_restore_current_win()
let curwin = win_getid()
vsplit Xb
wincmd p
botright copen
cclose
call assert_equal(curwin, win_getid())
bw! Xb
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -5245,7 +5245,7 @@ def Test_lockvar_islocked_notfound()
enddef
" Test for a protected object method
def Test_private_object_method()
def Test_protected_object_method()
# Try calling a protected method using an object (at the script level)
var lines =<< trim END
vim9script
@@ -5482,10 +5482,27 @@ def Test_private_object_method()
var a = _Foo()
END
v9.CheckSourceFailure(lines, 'E1267: Function name must start with a capital: _Foo(): number', 2)
# Test for initializing a protected funcref instance variable to a protected
# class method from another class
lines =<< trim END
vim9script
class A
static def _Internal(): string
enddef
endclass
class B
var Fn: func = A._Internal
endclass
var b = B.new()
END
v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Internal', 1)
enddef
" Test for an protected class method
def Test_private_class_method()
def Test_protected_class_method()
# Try calling a class protected method (at the script level)
var lines =<< trim END
vim9script
@@ -5680,6 +5697,22 @@ def Test_private_class_method()
assert_equal(1234, C._Foo())
END
v9.CheckSourceFailure(lines, 'E1325: Method "_Foo" not found in class "C"', 16)
# Test for initializing a protected funcref class variable to a protected
# class method from another class
lines =<< trim END
vim9script
class A
static def _Internal(): string
enddef
endclass
class B
static var Fn: func = A._Internal
endclass
END
v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Internal', 10)
enddef
" Test for using the return value of a class/object method as a function
@@ -5938,15 +5971,12 @@ def Test_dup_member_variable()
enddef
" Test for accessing a protected member outside a class in a def function
def Test_private_member_access_outside_class()
# protected object member variable
def Test_protected_member_access_outside_class()
# try to modify a protected instance variable from a def function
var lines =<< trim END
vim9script
class A
var _val = 10
def GetVal(): number
return this._val
enddef
endclass
def T()
var a = A.new()
@@ -5956,7 +5986,7 @@ def Test_private_member_access_outside_class()
END
v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_val" in class "A"', 2)
# access a non-existing protected object member variable
# access a non-existing protected instance variable from a def function
lines =<< trim END
vim9script
class A
@@ -5970,7 +6000,7 @@ def Test_private_member_access_outside_class()
END
v9.CheckSourceFailure(lines, 'E1326: Variable "_a" not found in object "A"', 2)
# protected static member variable
# try to read a protected class variable from a def function using an instance
lines =<< trim END
vim9script
class A
@@ -5984,7 +6014,8 @@ def Test_private_member_access_outside_class()
END
v9.CheckSourceFailure(lines, 'E1375: Class variable "_val" accessible only using class "A"', 2)
# protected static member variable
# try to modify a protected class variable from a def function using an
# instance
lines =<< trim END
vim9script
class A
@@ -5998,7 +6029,7 @@ def Test_private_member_access_outside_class()
END
v9.CheckSourceFailure(lines, 'E1375: Class variable "_val" accessible only using class "A"', 2)
# protected static class variable
# try to read a protected class variable from a def function using the class
lines =<< trim END
vim9script
class A
@@ -6011,7 +6042,7 @@ def Test_private_member_access_outside_class()
END
v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_val" in class "A"', 1)
# protected static class variable
# try to modify a protected class variable from a def function using the class
lines =<< trim END
vim9script
class A
@@ -6023,6 +6054,33 @@ def Test_private_member_access_outside_class()
T()
END
v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_val" in class "A"', 1)
# initialize a protected class variable using a protected class variable
# from another class
lines =<< trim END
vim9script
class A
static var _aval = 10
endclass
class B
static var _bval = A._aval
endclass
END
v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_aval" in class "A"', 7)
# initialize a protected instance variable using a protected class variable
# from another class
lines =<< trim END
vim9script
class A
static var _aval = 10
endclass
class B
var _bval = A._aval
endclass
var b = B.new()
END
v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_aval" in class "A"', 1)
enddef
" Test for changing the member access of an interface in a implementation class
@@ -7088,7 +7146,7 @@ def Test_extend_empty_class()
v9.CheckSourceSuccess(lines)
enddef
" A interface cannot have a static variable or a static method or a private
" A interface cannot have a static variable or a static method or a protected
" variable or a protected method or a public variable
def Test_interface_with_unsupported_members()
var lines =<< trim END
@@ -11686,7 +11744,7 @@ def Test_any_obj_var_type()
END
v9.CheckScriptSuccess(lines)
# Modifying an object private variable from a method in another class using
# Modifying an object protected variable from a method in another class using
# any type
lines =<< trim END
vim9script
@@ -11756,7 +11814,7 @@ def Test_any_obj_var_type()
END
v9.CheckScriptSuccess(lines)
# Try to modify a private object variable using a variable of type "any"
# Try to modify a protected object variable using a variable of type "any"
lines =<< trim END
vim9script

View File

@@ -734,6 +734,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2002,
/**/
2001,
/**/
2000,
/**/

View File

@@ -1314,6 +1314,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
#define WSP_ABOVE 0x80 // put new window above/left
#define WSP_NEWLOC 0x100 // don't copy location list
#define WSP_FORCE_ROOM 0x200 // ignore "not enough room" errors
#define WSP_QUICKFIX 0x400 // creating the quickfix window
/*
* arguments for gui_set_shellsize()

View File

@@ -2700,7 +2700,10 @@ early_ret:
// Allocate a typval for each class member and initialize it.
if ((is_class || is_enum) && cl->class_class_member_count > 0)
if (add_class_members(cl, eap, &type_list) == FAIL)
goto cleanup;
{
cl->class_type_list = type_list;
return;
}
cl->class_type_list = type_list;

View File

@@ -959,6 +959,11 @@ win_split(int size, int flags)
else
clear_snapshot(curtab, SNAP_HELP_IDX);
if (flags & WSP_QUICKFIX)
make_snapshot(SNAP_QUICKFIX_IDX);
else
clear_snapshot(curtab, SNAP_QUICKFIX_IDX);
return win_split_ins(size, flags, NULL, 0, NULL);
}
@@ -2688,6 +2693,7 @@ win_close(win_T *win, int free_buf)
int close_curwin = FALSE;
int dir;
int help_window = FALSE;
int quickfix_window = FALSE;
tabpage_T *prev_curtab = curtab;
frame_T *win_frame = win->w_frame->fr_parent;
#ifdef FEAT_DIFF
@@ -2740,6 +2746,11 @@ win_close(win_T *win, int free_buf)
else
clear_snapshot(curtab, SNAP_HELP_IDX);
if (bt_quickfix(win->w_buffer))
quickfix_window = TRUE;
else
clear_snapshot(curtab, SNAP_QUICKFIX_IDX);
if (win == curwin)
{
#ifdef FEAT_JOB_CHANNEL
@@ -2845,11 +2856,11 @@ win_close(win_T *win, int free_buf)
// the screen space.
wp = win_free_mem(win, &dir, NULL);
if (help_window)
if (help_window || quickfix_window)
{
// Closing the help window moves the cursor back to the current window
// of the snapshot.
win_T *prev_win = get_snapshot_curwin(SNAP_HELP_IDX);
win_T *prev_win = get_snapshot_curwin(help_window ? SNAP_HELP_IDX : SNAP_QUICKFIX_IDX);
if (win_valid(prev_win))
wp = prev_win;
@@ -2939,10 +2950,11 @@ win_close(win_T *win, int free_buf)
--dont_parse_messages;
#endif
// After closing the help window, try restoring the window layout from
// before it was opened.
if (help_window)
restore_snapshot(SNAP_HELP_IDX, close_curwin);
// After closing the help or quickfix window, try restoring the window
// layout from before it was opened.
if (help_window || quickfix_window)
restore_snapshot(help_window ? SNAP_HELP_IDX : SNAP_QUICKFIX_IDX,
close_curwin);
#ifdef FEAT_DIFF
// If the window had 'diff' set and now there is only one window left in