Skip to content

Commit 05e8f1d

Browse files
committed
Merge remote-tracking branch 'upstream/master' into tabsidebar
2 parents 1fd608f + 71f17fd commit 05e8f1d

File tree

6 files changed

+96
-6
lines changed

6 files changed

+96
-6
lines changed

runtime/autoload/rustfmt.vim

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
" Author: Stephen Sugden <[email protected]>
22
" Last Modified: 2023-09-11
3+
" Last Change: 2025 Mar 31 by Vim project (rename s:RustfmtConfigOptions())
34
"
45
" Adapted from https://github.com/fatih/vim-go
56
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
@@ -61,7 +62,7 @@ function! s:RustfmtWriteMode()
6162
endif
6263
endfunction
6364

64-
function! s:RustfmtConfigOptions()
65+
function! rustfmt#RustfmtConfigOptions()
6566
let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')
6667
if l:rustfmt_toml !=# ''
6768
return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p"))
@@ -84,7 +85,7 @@ function! s:RustfmtCommandRange(filename, line1, line2)
8485

8586
let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]}
8687
let l:write_mode = s:RustfmtWriteMode()
87-
let l:rustfmt_config = s:RustfmtConfigOptions()
88+
let l:rustfmt_config = rustfmt#RustfmtConfigOptions()
8889

8990
" FIXME: When --file-lines gets to be stable, add version range checking
9091
" accordingly.
@@ -99,7 +100,7 @@ endfunction
99100

100101
function! s:RustfmtCommand()
101102
let write_mode = g:rustfmt_emit_files ? '--emit=stdout' : '--write-mode=display'
102-
let config = s:RustfmtConfigOptions()
103+
let config = rustfmt#RustfmtConfigOptions()
103104
return join([g:rustfmt_command, write_mode, config, g:rustfmt_options])
104105
endfunction
105106

runtime/ftplugin/rust.vim

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
" Maintainer: Chris Morgan <[email protected]>
44
" Last Change: 2024 Mar 17
55
" 2024 May 23 by Riley Bruins <[email protected] ('commentstring')
6+
" 2025 Mar 31 by Vim project (set 'formatprg' option)
67
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
78

89
if exists("b:did_ftplugin")
@@ -57,6 +58,19 @@ setlocal includeexpr=rust#IncludeExpr(v:fname)
5758

5859
setlocal suffixesadd=.rs
5960

61+
if executable(get(g:, 'rustfmt_command', 'rustfmt'))
62+
if get(g:, "rustfmt_fail_silently", 0)
63+
augroup rust.vim.FailSilently
64+
autocmd! * <buffer>
65+
autocmd ShellFilterPost <buffer> if v:shell_error | execute 'echom "shell filter returned error " . v:shell_error . ", undoing changes"' | undo | endif
66+
augroup END
67+
endif
68+
69+
let &l:formatprg = get(g:, 'rustfmt_command', 'rustfmt') . ' ' .
70+
\ get(g:, 'rustfmt_options', '') . ' ' .
71+
\ rustfmt#RustfmtConfigOptions()
72+
endif
73+
6074
if exists("g:ftplugin_rust_source_path")
6175
let &l:path=g:ftplugin_rust_source_path . ',' . &l:path
6276
endif
@@ -149,7 +163,7 @@ endif
149163

150164
let b:undo_ftplugin = "
151165
\ compiler make |
152-
\ setlocal formatoptions< comments< commentstring< include< includeexpr< suffixesadd<
166+
\ setlocal formatoptions< comments< commentstring< include< includeexpr< suffixesadd< formatprg<
153167
\|if exists('b:rust_set_style')
154168
\|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth<
155169
\|endif

src/testdir/test_ins_complete.vim

+29
Original file line numberDiff line numberDiff line change
@@ -3387,4 +3387,33 @@ func Test_complete_multiline_marks()
33873387
delfunc Omni_test
33883388
endfunc
33893389

3390+
func Test_complete_append_selected_match_default()
3391+
" when typing a normal character during completion,
3392+
" completion is ended, see
3393+
" :h popupmenu-completion ("There are three states:")
3394+
func PrintMenuWords()
3395+
let info = complete_info(["selected", "matches"])
3396+
call map(info.matches, {_, v -> v.word})
3397+
return info
3398+
endfunc
3399+
3400+
new
3401+
call setline(1, ["fo", "foo", "foobar", "fobarbaz"])
3402+
exe "normal! Gof\<c-n>\<c-r>=PrintMenuWords()\<cr>"
3403+
call assert_equal('fo{''matches'': [''fo'', ''foo'', ''foobar'', ''fobarbaz''], ''selected'': 0}', getline(5))
3404+
%d
3405+
call setline(1, ["fo", "foo", "foobar", "fobarbaz"])
3406+
exe "normal! Gof\<c-n>o\<c-r>=PrintMenuWords()\<cr>"
3407+
call assert_equal('foo{''matches'': [], ''selected'': -1}', getline(5))
3408+
%d
3409+
set completeopt=menu,noselect
3410+
call setline(1, ["fo", "foo", "foobar", "fobarbaz"])
3411+
exe "normal! Gof\<c-n>\<c-n>o\<c-r>=PrintMenuWords()\<cr>"
3412+
call assert_equal('foo{''matches'': [], ''selected'': -1}', getline(5))
3413+
bw!
3414+
3415+
set completeopt&
3416+
delfunc PrintMenuWords
3417+
endfunc
3418+
33903419
" vim: shiftwidth=2 sts=2 expandtab nofoldenable

src/testdir/test_vim9_class.vim

+40
Original file line numberDiff line numberDiff line change
@@ -12481,4 +12481,44 @@ def Test_super_keyword()
1248112481
v9.CheckSourceSuccess(lines)
1248212482
enddef
1248312483

12484+
" Test for using a list of objects
12485+
def Test_method_call_from_list_of_objects()
12486+
var lines =<< trim END
12487+
vim9script
12488+
12489+
class C
12490+
def F(): string
12491+
return 'C.F'
12492+
enddef
12493+
endclass
12494+
12495+
class D
12496+
var x: string
12497+
def new(this.x)
12498+
enddef
12499+
def F(): string
12500+
return 'D.F'
12501+
enddef
12502+
endclass
12503+
12504+
var obj1 = C.new()
12505+
var obj2 = D.new('a')
12506+
12507+
def CheckObjectList()
12508+
var items = [obj1, obj2]
12509+
assert_equal('list<any>', typename(items))
12510+
assert_equal('C.F', items[0].F())
12511+
assert_equal('D.F', items[1].F())
12512+
enddef
12513+
12514+
CheckObjectList()
12515+
12516+
var items2 = [obj1, obj2]
12517+
assert_equal('list<any>', typename(items2))
12518+
assert_equal('C.F', items2[0].F())
12519+
assert_equal('D.F', items2[1].F())
12520+
END
12521+
v9.CheckSourceSuccess(lines)
12522+
enddef
12523+
1248412524
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

src/version.c

+4
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ static char *(features[]) =
709709

710710
static int included_patches[] =
711711
{ /* Add new patch number below this line */
712+
/**/
713+
1265,
714+
/**/
715+
1264,
712716
/**/
713717
1263,
714718
/**/

src/vim9type.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1984,10 +1984,12 @@ equal_type(type_T *type1, type_T *type2, int flags)
19841984
case VAR_JOB:
19851985
case VAR_CHANNEL:
19861986
case VAR_INSTR:
1987-
case VAR_CLASS:
1988-
case VAR_OBJECT:
19891987
case VAR_TYPEALIAS:
19901988
break; // not composite is always OK
1989+
case VAR_OBJECT:
1990+
case VAR_CLASS:
1991+
// Objects are considered equal if they are from the same class
1992+
return type1->tt_class == type2->tt_class;
19911993
case VAR_LIST:
19921994
case VAR_DICT:
19931995
return equal_type(type1->tt_member, type2->tt_member, flags);

0 commit comments

Comments
 (0)