view src/testdir/test_remote.vim @ 34379:37b4c89ba420 v9.1.0116

patch 9.1.0116: win_split_ins may not check available room Commit: https://github.com/vim/vim/commit/0fd44a5ad81ade342cb54d8984965bdedd2272c8 Author: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Tue Feb 20 20:28:15 2024 +0100 patch 9.1.0116: win_split_ins may not check available room Problem: win_split_ins has no check for E36 when moving an existing window Solution: check for room and fix the issues in f_win_splitmove() (Sean Dewar) win_split_ins has no check for E36 when moving an existing window, allowing for layouts with many overlapping zero-sized windows to be created (which may also cause drawing issues with tablines and such). f_win_splitmove also has some bugs. So check for room and fix the issues in f_win_splitmove. Handle failure in the two relevant win_split_ins callers by restoring the original layout, and factor the common logic into win_splitmove. Don't check for room when opening an autocommand window, as it's a temporary window that's rarely interacted with or drawn anyhow, and is rather important for some autocommands. Issues fixed in f_win_splitmove: - Error if splitting is disallowed. - Fix heap-use-after-frees if autocommands fired from switching to "targetwin" close "wp" or "oldwin". - Fix splitting the wrong window if autocommands fired from switching to "targetwin" switch to a different window. - Ensure -1 is returned for all errors. Also handle allocation failure a bit earlier in make_snapshot (callers, except win_splitmove, don't really care if a snapshot can't be made, so just ignore the return value). Note: Test_smoothscroll_in_zero_width_window failed after these changes with E36, as it was using the previous behaviour to create a zero-width window. I've fixed the test such that it fails with UBSAN as expected when v9.0.1367 is reverted (and simplified it too). related: #14042 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 20 Feb 2024 22:30:04 +0100
parents 6315b95cba59
children e71b9c9debfe
line wrap: on
line source

" Test for the --remote functionality

source check.vim
CheckFeature clientserver
CheckFeature terminal

source shared.vim
source screendump.vim
source mouse.vim
source term_util.vim

let s:remote_works = 0
let s:skip = 'Skipped: --remote feature is not possible'

" nees to be run as first test to verify, that vim --servername works
func Verify_remote_feature_works()
  CheckRunVimInTerminal
  enew
  let buf = RunVimInTerminal('--servername XVIMTEST', {'rows': 8})
  call TermWait(buf)
  let cmd = GetVimCommandCleanTerm() .. '--serverlist'
  call term_sendkeys(buf, ":r! " .. cmd .. "\<CR>")
  call TermWait(buf)
  call term_sendkeys(buf, ":w! XVimRemoteTest.txt\<CR>")
  call TermWait(buf)
  call term_sendkeys(buf, ":q\<CR>")
  call StopVimInTerminal(buf)
  bw!
  let result = readfile('XVimRemoteTest.txt')
  call delete('XVimRemoteTest.txt')
  if empty(result)
    throw s:skip
  endif
  let s:remote = 1
endfunc

call Verify_remote_feature_works()

if !s:remote
  finish
endif

func Test_remote_servername()
  CheckRunVimInTerminal

  " That is the file we want the server to open,
  " despite the wildignore setting
  call writefile(range(1, 20), 'XTEST.txt', 'D')
  " just a dummy file, so that the ':wq' further down is successful
  call writefile(range(1, 20), 'Xdummy.log', 'D')

  " Run Vim in a terminal and open a terminal window to run Vim in.
  let lines =<< trim END
    set wildignore=*.txt
  END
  call writefile(lines, 'XRemoteEditing.vim', 'D')
  let buf = RunVimInTerminal('--servername XVIMTEST -S XRemoteEditing.vim  Xdummy.log', {'rows': 8})
  call TermWait(buf)
  botright new
  " wildignore setting should be ignored and the XVIMTEST server should now
  " open XTEST.txt, if wildignore setting is not ignored, the server
  " will continue with the Xdummy.log file
  let buf2 = RunVimInTerminal('--servername XVIMTEST --remote-silent XTEST.txt', {'rows': 5, 'wait_for_ruler': 0})
  " job should be no-longer running, so we can just close it
  exe buf2 .. 'bw!'
  call term_sendkeys(buf, ":sil :3,$d\<CR>")
  call TermWait(buf)
  call term_sendkeys(buf, ":wq!\<CR>")
  call TermWait(buf)
  if term_getstatus(buf) == 'running'
    call StopVimInTerminal(buf)
  endif
  let buf_contents = readfile('XTEST.txt')
  call assert_equal(2, len(buf_contents))
  bw!
  close
endfunc

" vim: shiftwidth=2 sts=2 expandtab