diff --git a/.gitignore b/.gitignore index 38fb5e692f..b99aa3fd3f 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ src/pathdef.c src/Obj*/pathdef.c gvimext.dll gvimext.lib +gvim.lib runtime/doc/uganda.nsis.txt # Borland C++ diff --git a/Filelist b/Filelist index aaa6ba77ad..8b3449c0e5 100644 --- a/Filelist +++ b/Filelist @@ -406,6 +406,7 @@ SRC_DOS = \ src/msvcsetup.bat \ src/msvc2008.bat \ src/msvc2010.bat \ + src/msvc2015.bat \ src/dimm.idl \ src/dlldata.c \ src/dosinst.c \ diff --git a/Makefile b/Makefile index d19831615b..a45af5a993 100644 --- a/Makefile +++ b/Makefile @@ -120,28 +120,28 @@ MINOR = 0 # # MS-Windows: # - Run make on Unix to update the ".mo" files. -# - Get libintl-8.dll, libiconv-2.dll and libgcc_s_sjlj-1.dll. E.g. from +# - Get 32 bit libintl-8.dll, libiconv-2.dll and libgcc_s_sjlj-1.dll. E.g. from # https://mlocati.github.io/gettext-iconv-windows/ . # Use the "shared-32.zip file and extract the archive to get the files. -# Put them in the top directory, "make dosrt" uses them. +# Put them in the gettext32 directory, "make dosrt" uses them. +# - Get 64 bit libintl-8.dll and libiconv-2.dll. E.g. from +# https://mlocati.github.io/gettext-iconv-windows/ . +# Use the "shared-64.zip file and extract the archive to get the files. +# Put them in the gettext64 directory, "make dosrt" uses them. # - > make dossrc # > make dosrt # Unpack dist/vim##rt.zip and dist/vim##src.zip on an MS-Windows PC. +# This creates the directory vim/vim80 and puts all files in there. # Win32 console version build: -# - Set environment for Visual C++ 2008, e.g.: -# > src/msvc2008.bat -# Or: -# > C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat -# Or, when using the Visual C++ Toolkit 2003: "msvcsetup.bat" (adjust the -# paths when necessary). -# For Windows 98/ME the 2003 version is required, but then the executable -# won't work on Windows 7 and 64 bit systems. -# - > cd src +# - See src/INSTALLpc.txt for installing the compiler and SDK. +# - Set environment for Visual C++ 2015: +# > cd src +# > msvc2015.bat +# - Build the console binary: # > nmake -f Make_mvc.mak -# - Run the tests: +# - Run the tests and check the ouput: # > nmake -f Make_mvc.mak testclean # > nmake -f Make_mvc.mak test -# - check the output. # - Rename (using ../tools/rename.bat): # vim.exe to vimw32.exe # tee/tee.exe to teew32.exe @@ -152,19 +152,18 @@ MINOR = 0 # Win32 GUI version build: # - > cd src # > nmake -f Make_mvc.mak GUI=yes -# - Run the tests: +# - Run the tests and check the output: # > nmake -f Make_mvc.mak testclean # > nmake -f Make_mvc.mak testgvim -# - check the output. # - move "gvim.exe" to here (otherwise the OLE version will overwrite it). # - Move gvim.pdb to here. # - Copy "GvimExt/gvimext.dll" to here. # - Delete vimrun.exe, install.exe and uninstal.exe. # Win32 GUI version with OLE, PERL, Ruby, TCL, PYTHON and dynamic IME: # - Install the interfaces you want, see src/INSTALLpc.txt +# Adjust bigvim.bat to match the version of each interface you want. # - Build: # > cd src -# Adjust bigvim.bat to match the version of each interface you want. # > bigvim.bat # - Run the tests: # > nmake -f Make_mvc.mak testclean @@ -188,10 +187,11 @@ MINOR = 0 # gvimext64.dll in src/GvimExt # VisVim.dll in src/VisVim # Note: VisVim needs to be build with MSVC 5, newer versions don't work. -# gvimext64.dll can be obtained from http://code.google.com/p/vim-win3264/ -# It is part of vim72.zip as vim72/gvimext.dll. +# gvimext64.dll can be obtained from: +# https://github.com/vim/vim-win32-installer/releases +# It is part of gvim_8.0.*_x64.zip as vim/vim80/GvimExt/gvimext64.dll. # - Make sure there is a diff.exe two levels up (get it from a previous Vim -# version). +# version). Also put winpty32.dll and winpty-agent.exe there. # - go to ../nsis and do: # > makensis gvim.nsi (takes a few minutes). # ignore warning for libwinpthread-1.dll @@ -467,9 +467,13 @@ dosrt_files: dist prepare no_title.vim cp $$i dist/vim/$(VIMRTDIR)/lang/$$n/LC_MESSAGES/vim.mo; \ fi \ done - cp libintl-8.dll dist/vim/$(VIMRTDIR)/ - cp libiconv-2.dll dist/vim/$(VIMRTDIR)/ - cp libgcc_s_sjlj-1.dll dist/vim/$(VIMRTDIR)/ + mkdir dist/vim/$(VIMRTDIR)/gettext32 + cp gettext32/libintl-8.dll dist/vim/$(VIMRTDIR)/gettext32/ + cp gettext32/libiconv-2.dll dist/vim/$(VIMRTDIR)/gettext32/ + cp gettext32/libgcc_s_sjlj-1.dll dist/vim/$(VIMRTDIR)/gettext32/ + mkdir dist/vim/$(VIMRTDIR)/gettext64 + cp gettext64/libintl-8.dll dist/vim/$(VIMRTDIR)/gettext64/ + cp gettext64/libiconv-2.dll dist/vim/$(VIMRTDIR)/gettext64/ # Used before uploading. Don't delete the AAPDIR/sign files! @@ -496,7 +500,10 @@ dosbin_gvim: dist no_title.vim dist/$(COMMENT_GVIM) cp vimrun.exe dist/vim/$(VIMRTDIR)/vimrun.exe cp installw32.exe dist/vim/$(VIMRTDIR)/install.exe cp uninstalw32.exe dist/vim/$(VIMRTDIR)/uninstal.exe - cp gvimext.dll dist/vim/$(VIMRTDIR)/gvimext.dll + mkdir dist/vim/$(VIMRTDIR)/GvimExt32 + cp gvimext.dll dist/vim/$(VIMRTDIR)/GvimExt32/gvimext.dll + mkdir dist/vim/$(VIMRTDIR)/GvimExt64 + cp gvimext64.dll dist/vim/$(VIMRTDIR)/GvimExt64/gvimext.dll cd dist && zip -9 -rD -z gvim$(VERSION).zip vim <$(COMMENT_GVIM) cp gvim.pdb dist/gvim$(VERSION).pdb diff --git a/nsis/README.txt b/nsis/README.txt index ad209e9f6d..b61580c9b0 100644 --- a/nsis/README.txt +++ b/nsis/README.txt @@ -1,5 +1,5 @@ This builds a one-click install for Vim for Win32 using the Nullsoft -Installation System (NSIS), available at http://www.nullsoft.com/free/nsis/ +Installation System (NSIS), available at http://nsis.sourceforge.net/ To build the installable .exe: @@ -17,8 +17,14 @@ To build the installable .exe: uninstal.exe, xxd/xxd.exe, + Then execute tools/rename.bat to rename the executables. (mv command is + required.) + 3. Go to the GvimExt directory and build gvimext.dll (or get it from a binary - archive). + archive). Both 64- and 32-bit versions are needed and should be placed + as follows: + 64-bit: src/GvimExt/gvimext64.dll + 32-bit: src/GvimExt/gvimext.dll 4. Go to the VisVim directory and build VisVim.dll (or get it from a binary archive). @@ -27,13 +33,35 @@ To build the installable .exe: get them from a binary archive). 6. Get a "diff.exe" program and put it in the "../.." directory (above the - "vim61" directory, it's the same for all Vim versions). + "vim80" directory, it's the same for all Vim versions). You can find one in previous Vim versions or in this archive: http://www.mossbayeng.com/~ron/vim/diffutils.tar.gz + Also put winpty32.dll and winpty-agent.exe there. 7. Do "make uganda.nsis.txt" in runtime/doc. This requires sed, you may have to do this on Unix. Make sure the file is in DOS file format! +8. Get gettext and iconv DLLs from the following site: + https://github.com/mlocati/gettext-iconv-windows/releases + Both 64- and 32-bit versions are needed. + Download the files gettextX.X.X.X-iconvX.XX-shared-{32,64}.zip, extract + DLLs and place them as follows: + + + | + + gettext32/ + | libintl-8.dll + | libiconv-2.dll + | libgcc_s_sjlj-1.dll + | + ` gettext64/ + libintl-8.dll + libiconv-2.dll + + The default is "..", however, you can change it by + passing /DGETTEXT=... option to the makensis command. + + Install NSIS if you didn't do that already. Also install UPX, if you want a compressed file. diff --git a/nsis/gvim.nsi b/nsis/gvim.nsi index 1a169f3e00..8447d5ffee 100644 --- a/nsis/gvim.nsi +++ b/nsis/gvim.nsi @@ -20,8 +20,15 @@ !define VIMTOOLS ..\.. !endif +# Location of gettext. +# It must contain two directories: gettext32 and gettext64. +# See README.txt for detail. +!ifndef GETTEXT + !define GETTEXT ${VIMRT} +!endif + # Comment the next line if you don't have UPX. -# Get it at http://upx.sourceforge.net +# Get it at https://upx.github.io/ !define HAVE_UPX # comment the next line if you do not want to add Native Language Support @@ -328,24 +335,67 @@ Section "Add an Edit-with-Vim context menu entry" SetOutPath $0 ClearErrors SetOverwrite try + ${If} ${RunningX64} + # Install 64-bit gvimext.dll into the GvimExt64 directory. + SetOutPath $0\GvimExt64 + ClearErrors File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext64.dll - ${Else} - File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext.dll +!ifdef HAVE_NLS + File ${GETTEXT}\gettext64\libintl-8.dll + File ${GETTEXT}\gettext64\libiconv-2.dll +!endif + + IfErrors 0 GvimExt64Done + + # Can't copy gvimext.dll, create it under another name and rename it + # on next reboot. + GetTempFileName $3 $0\GvimExt64 + File /oname=$3 ${VIMSRC}\GvimExt\gvimext64.dll + Rename /REBOOTOK $3 $0\GvimExt64\gvimext.dll +!ifdef HAVE_NLS + GetTempFileName $3 $0\GvimExt64 + File /oname=$3 ${GETTEXT}\gettext64\libintl-8.dll + Rename /REBOOTOK $3 $0\GvimExt64\libintl-8.dll + GetTempFileName $3 $0\GvimExt64 + File /oname=$3 ${GETTEXT}\gettext64\libiconv-2.dll + Rename /REBOOTOK $3 $0\GvimExt64\libiconv-2.dll +!endif ${EndIf} - IfErrors 0 GvimExtDone + + GvimExt64Done: + + # Install 32-bit gvimext.dll into the GvimExt32 directory. + SetOutPath $0\GvimExt32 + ClearErrors + + File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext.dll +!ifdef HAVE_NLS + File ${GETTEXT}\gettext32\libintl-8.dll + File ${GETTEXT}\gettext32\libiconv-2.dll + File ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll +!endif + + IfErrors 0 GvimExt32Done # Can't copy gvimext.dll, create it under another name and rename it on # next reboot. - GetTempFileName $3 $0 - ${If} ${RunningX64} - File /oname=$3 ${VIMSRC}\GvimExt\gvimext64.dll - ${Else} - File /oname=$3 ${VIMSRC}\GvimExt\gvimext.dll - ${EndIf} - Rename /REBOOTOK $3 $0\gvimext.dll + GetTempFileName $3 $0\GvimExt32 + File /oname=$3 ${VIMSRC}\GvimExt\gvimext.dll + Rename /REBOOTOK $3 $0\GvimExt32\gvimext.dll +!ifdef HAVE_NLS + GetTempFileName $3 $0\GvimExt32 + File /oname=$3 ${GETTEXT}\gettext32\libintl-8.dll + Rename /REBOOTOK $3 $0\GvimExt32\libintl-8.dll + GetTempFileName $3 $0\GvimExt32 + File /oname=$3 ${GETTEXT}\gettext32\libiconv-2.dll + Rename /REBOOTOK $3 $0\GvimExt32\libiconv-2.dll + GetTempFileName $3 $0\GvimExt32 + File /oname=$3 ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll + Rename /REBOOTOK $3 $0\GvimExt32\libgcc_s_sjlj-1.dll +!endif - GvimExtDone: + GvimExt32Done: SetOverwrite lastused # We don't have a separate entry for the "Open With..." menu, assume @@ -394,10 +444,10 @@ SectionEnd File ${VIMRT}\keymap\README.txt File ${VIMRT}\keymap\*.vim SetOutPath $0 - File ${VIMRT}\libintl-8.dll - File ${VIMRT}\libiconv-2.dll - File /nonfatal ${VIMRT}\libwinpthread-1.dll - File /nonfatal ${VIMRT}\libgcc_s_sjlj-1.dll + File ${GETTEXT}\gettext32\libintl-8.dll + File ${GETTEXT}\gettext32\libiconv-2.dll + #File /nonfatal ${VIMRT}\libwinpthread-1.dll + File /nonfatal ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll SectionEnd !endif @@ -437,6 +487,11 @@ Section Uninstall $\nIt contains the Vim executables and runtime files." IDNO NoRemoveExes Delete /REBOOTOK $0\*.dll + Delete /REBOOTOK $0\GvimExt32\*.dll + ${If} ${RunningX64} + Delete /REBOOTOK $0\GvimExt64\*.dll + ${EndIf} + ClearErrors # Remove everything but *.dll files. Avoids that # a lot remains when gvimext.dll cannot be deleted. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 94e47245a7..99210328d4 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1912,11 +1912,16 @@ v:termstyleresp The escape sequence returned by the terminal for the |t_RS| termcap entry. This is used to find out what the shape of the cursor is. This is used by |term_getcursor()|. - *v:termrgbresp* -v:termrgbresp The escape sequence returned by the terminal for the |t_RB| + *v:termrbgresp* +v:termrbgresp The escape sequence returned by the terminal for the |t_RB| termcap entry. This is used to find out what the terminal background color is, see 'background'. + *v:termrfgresp* +v:termrfgresp The escape sequence returned by the terminal for the |t_RF| + termcap entry. This is used to find out what the terminal + foreground color is. + *v:termu7resp* v:termu7resp The escape sequence returned by the terminal for the |t_u7| termcap entry. This is used to find out what the terminal diff --git a/runtime/doc/if_mzsch.txt b/runtime/doc/if_mzsch.txt index 7e206f5190..a9a03139f4 100644 --- a/runtime/doc/if_mzsch.txt +++ b/runtime/doc/if_mzsch.txt @@ -1,4 +1,4 @@ -*if_mzsch.txt* For Vim version 8.0. Last change: 2016 Jan 24 +*if_mzsch.txt* For Vim version 8.0. Last change: 2017 Oct 08 VIM REFERENCE MANUAL by Sergey Khorev @@ -278,12 +278,15 @@ When you don't use the MzScheme interface you don't need them, thus you can use Vim without these DLL files. NOTE: Newer version of MzScheme (Racket) require earlier (trampolined) initialisation via scheme_main_setup. So Vim always loads the MzScheme DLL at -startup if possible. +startup if possible. This may make Vim startup slower. To use the MzScheme interface the MzScheme DLLs must be in your search path. In a console window type "path" to see what directories are used. -The names of the DLLs must match the MzScheme version Vim was compiled with. +On MS-Windows the options 'mzschemedll' and 'mzschemegcdll' are used for the +name of the library to load. The initial value is specified at build time. + +The version of the DLL must match the MzScheme version Vim was compiled with. For MzScheme version 209 they will be "libmzsch209_000.dll" and "libmzgc209_000.dll". To know for sure look at the output of the ":version" command, look for -DDYNAMIC_MZSCH_DLL="something" and diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index 5eeba0cf4a..dbc4280b70 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -463,12 +463,6 @@ changed. To avoid the message reset the 'warn' option. Something inside Vim went wrong and resulted in a NULL pointer. If you know how to reproduce this problem, please report it. |bugs| - *E172* > - Only one file name allowed - -The ":edit" command only accepts one file name. When you want to specify -several files for editing use ":next" |:next|. - *E41* *E82* *E83* *E342* > Out of memory! Out of memory! (allocating {number} bytes) diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index 673d1c572a..85d0c4ace8 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -1317,7 +1317,10 @@ the current line is included. You can then use "%" to go to the matching line. H To line [count] from top (Home) of window (default: first line on the window) on the first non-blank character |linewise|. See also 'startofline' option. - Cursor is adjusted for 'scrolloff' option. + Cursor is adjusted for 'scrolloff' option, unless an + operator is pending, in which case the text may + scroll. E.g. "yH" yanks from the first visible line + until the cursor line (inclusive). *M* M To Middle line of window, on the first non-blank @@ -1327,7 +1330,10 @@ M To Middle line of window, on the first non-blank L To line [count] from bottom of window (default: Last line on the window) on the first non-blank character |linewise|. See also 'startofline' option. - Cursor is adjusted for 'scrolloff' option. + Cursor is adjusted for 'scrolloff' option, unless an + operator is pending, in which case the text may + scroll. E.g. "yL" yanks from the cursor to the last + visible line. Moves to the position on the screen where the mouse click is |exclusive|. See also ||. If the diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index e3507bf3c1..bdfe1a9b03 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5630,6 +5630,31 @@ A jump table for the options with a short description can be found at |Q_op|. time in msec between two mouse clicks for the second click to be recognized as a multi click. + *'mzschemedll'* +'mzschemedll' string (default depends on the build) + global + {not in Vi} + {only available when compiled with the |+mzscheme/dyn| + feature} + Specifies the name of the MzScheme shared library. The default is + DYNAMIC_MZSCH_DLL which was specified at compile time. + Environment variables are expanded |:set_env|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'mzschemegcdll'* +'mzschemegcdll' string (default depends on the build) + global + {not in Vi} + {only available when compiled with the |+mzscheme/dyn| + feature} + Specifies the name of the MzScheme GC shared library. The default is + DYNAMIC_MZGC_DLL which was specified at compile time. + The value can be equal to 'mzschemedll' if it includes the GC code. + Environment variables are expanded |:set_env|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + *'mzquantum'* *'mzq'* 'mzquantum' 'mzq' number (default 100) global diff --git a/src/GvimExt/Makefile b/src/GvimExt/Makefile index c681d33528..27ff953e23 100644 --- a/src/GvimExt/Makefile +++ b/src/GvimExt/Makefile @@ -51,14 +51,17 @@ olelibsdll = ole32.lib uuid.lib oleaut32.lib user32.lib gdi32.lib advapi32.lib # include CPUARG cflags = $(cflags) $(CPUARG) +SUBSYSTEM = console +!if "$(SUBSYSTEM_VER)" != "" +SUBSYSTEM = $(SUBSYSTEM),$(SUBSYSTEM_VER) +!endif + all: gvimext.dll gvimext.dll: gvimext.obj \ gvimext.res -# $(implib) /NOLOGO -machine:$(CPU) -def:gvimext.def $** -out:gvimext.lib -# $(link) $(dlllflags) -base:0x1C000000 -out:$*.dll $** $(olelibsdll) shell32.lib gvimext.lib comctl32.lib gvimext.exp - $(link) $(lflags) -dll -def:gvimext.def -base:0x1C000000 -out:$*.dll $** $(olelibsdll) shell32.lib comctl32.lib - if exist $*.dll.manifest mt -nologo -manifest $*.dll.manifest -outputresource:$*.dll;2 + $(link) $(lflags) -dll -def:gvimext.def -base:0x1C000000 -out:$*.dll $** $(olelibsdll) shell32.lib comctl32.lib -subsystem:$(SUBSYSTEM) + if exist $*.dll.manifest mt -nologo -manifest $*.dll.manifest -outputresource:$*.dll;2 gvimext.obj: gvimext.h diff --git a/src/GvimExt/gvimext.cpp b/src/GvimExt/gvimext.cpp index b682b7429f..2b9f1ad8f7 100644 --- a/src/GvimExt/gvimext.cpp +++ b/src/GvimExt/gvimext.cpp @@ -38,7 +38,7 @@ STGMEDIUM medium; HRESULT hres = 0; UINT cbFiles = 0; -/* The buffers size used to be MAX_PATH (256 bytes), but that's not always +/* The buffers size used to be MAX_PATH (260 bytes), but that's not always * enough */ #define BUFSIZE 1100 @@ -203,7 +203,7 @@ dyn_libintl_init(char *dir) if (hLibintlDLL) return 1; - // Load gettext library from the Vim runtime directory. + // Load gettext library from $VIMRUNTIME\GvimExt{64,32} directory. // Add the directory to $PATH temporarily. len = GetEnvironmentVariableW(L"PATH", NULL, 0); len2 = MAX_PATH + 1 + len; @@ -212,7 +212,11 @@ dyn_libintl_init(char *dir) if (buf != NULL && buf2 != NULL) { GetEnvironmentVariableW(L"PATH", buf, len); - _snwprintf(buf2, len2, L"%S;%s", dir, buf); +#ifdef _WIN64 + _snwprintf(buf2, len2, L"%S\\GvimExt64;%s", dir, buf); +#else + _snwprintf(buf2, len2, L"%S\\GvimExt32;%s", dir, buf); +#endif SetEnvironmentVariableW(L"PATH", buf2); hLibintlDLL = LoadLibrary(GETTEXT_DLL); #ifdef GETTEXT_DLL_ALT @@ -883,37 +887,7 @@ BOOL CShellExt::LoadMenuIcon() return TRUE; } -#ifdef WIN32 -// This symbol is not defined in older versions of the SDK or Visual C++. - -#ifndef VER_PLATFORM_WIN32_WINDOWS -# define VER_PLATFORM_WIN32_WINDOWS 1 -#endif - -static DWORD g_PlatformId; - -// -// Set g_PlatformId to VER_PLATFORM_WIN32_NT (NT) or -// VER_PLATFORM_WIN32_WINDOWS (Win95). -// - static void -PlatformId(void) -{ - static int done = FALSE; - - if (!done) - { - OSVERSIONINFO ovi; - - ovi.dwOSVersionInfoSize = sizeof(ovi); - GetVersionEx(&ovi); - - g_PlatformId = ovi.dwPlatformId; - done = TRUE; - } -} - -# ifndef __BORLANDC__ +#ifndef __BORLANDC__ static char * searchpath(char *name) { @@ -922,28 +896,17 @@ searchpath(char *name) // There appears to be a bug in FindExecutableA() on Windows NT. // Use FindExecutableW() instead... - PlatformId(); - if (g_PlatformId == VER_PLATFORM_WIN32_NT) + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)name, -1, + (LPWSTR)widename, BUFSIZE); + if (FindExecutableW((LPCWSTR)widename, (LPCWSTR)"", + (LPWSTR)location) > (HINSTANCE)32) { - MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)name, -1, - (LPWSTR)widename, BUFSIZE); - if (FindExecutableW((LPCWSTR)widename, (LPCWSTR)"", - (LPWSTR)location) > (HINSTANCE)32) - { - WideCharToMultiByte(CP_ACP, 0, (LPWSTR)location, -1, - (LPSTR)widename, 2 * BUFSIZE, NULL, NULL); - return widename; - } - } - else - { - if (FindExecutableA((LPCTSTR)name, (LPCTSTR)"", - (LPTSTR)location) > (HINSTANCE)32) - return location; + WideCharToMultiByte(CP_ACP, 0, (LPWSTR)location, -1, + (LPSTR)widename, 2 * BUFSIZE, NULL, NULL); + return widename; } return (char *)""; } -# endif #endif STDMETHODIMP CShellExt::InvokeGvim(HWND hParent, diff --git a/src/INSTALLpc.txt b/src/INSTALLpc.txt index 8607e9ddad..0ed5e2f4a7 100644 --- a/src/INSTALLpc.txt +++ b/src/INSTALLpc.txt @@ -3,9 +3,9 @@ INSTALLpc.txt - Installation of Vim on PC This file contains instructions for compiling Vim. If you already have an executable version of Vim, you don't need this. -More information can be found here: (Very stale now.) - - http://mywebpage.netscape.com/sharppeople/vim/howto/ +You can find the lastest here: https://github.com/vim/vim-win32-installer +This page also has links to install support for interfaces such as Perl, +Python, Lua, etc. The file "feature.h" can be edited to match your preferences. You can skip this, then you will get the default behavior as is documented, which should @@ -15,6 +15,10 @@ This document assumes that you are building Vim for Win32 or later (Windows XP/2003/Vista/7/8/10). There are also instructions for pre-XP systems, but they might no longer work. +The recommended way is to build a 32 bit Vim, also on 64 bit systems. You can +build a 64 bit Vim if you like, the executable will be bigger and Vim wan't be +any faster, but you can edit files larger than 2 Gbyte. + Contents: 1. Microsoft Visual C++ @@ -24,7 +28,7 @@ Contents: 5. Cross compiling for Win32 from a Linux machine 6. Building with Python support 7. Building with Python3 support -8. Building with MzScheme/Racket support +8. Building with Racket or MzScheme support 9. Building with Lua support 10. Building with Perl support 11. Building with Ruby support @@ -36,13 +40,20 @@ Contents: 16. Installing after building from sources -The currently preferred method is using the free Visual C++ Toolkit 2008 -|msvc-2008-express|, the produced binary runs on most MS-Windows systems. +The currently recommended way (that means it has been verified to work) is +using the "Visual Studio Community 2015" installation. This includes the SDK +needed to target Windows XP. But not older Windows versions (95, 97), see +|msvc-2008-express| below for that 1. Microsoft Visual C++ ======================= +We do not provide download links, since Microsoft keeps changing them. You +can search for "Visual Studio Community 2015", for example. You will need to +create a Microsoft account (it's free). + + Visual Studio ------------- @@ -50,9 +61,8 @@ Building with Visual Studio (VS 98, VS .NET, VS .NET 2003, VS 2005, VS 2008, VS2010, VS2012, VS2013 and VS2015) is straightforward. (These instructions should also work for VS 4 and VS 5.) -Using VS C++ 2008 Express is recommended, the binaries built with that run on -nearly all platforms. Binaries from later versions may not run on Windows 95 -or XP. +Using VS C++ 2008 Express is recommended if you need the binary to run on +Windows 95 or 97, see |msvc-2008-express| below. To build Vim from the command line with MSVC, use Make_mvc.mak. Visual Studio installed a batch file called vcvars32.bat, which you must @@ -117,8 +127,8 @@ To set the environment execute the msvc2010.bat script. You can then build Vim with Make_mvc.mak. -Targeting Windows XP with new MSVC *new-msvc-windows-xp* ----------------------------------- +Targeting Windows XP with MSVC 2012 and later *new-msvc-windows-xp* +--------------------------------------------- Beginning with Visual C++ 2012, Microsoft changed the behavior of LINK.EXE so that it targets Windows 6.0 (Vista) by default. In order to override @@ -127,16 +137,28 @@ follows: LINK ... /subsystem:console,5.01 Make_mvc.mak now supports a macro SUBSYSTEM_VER to pass the Windows version. -Use lines like follows to target Windows XP (assuming using Visual C++ 2012 -under 64-bit Windows): +Use lines like follows to target Windows XP x86 (assuming using Visual C++ +2012 under 64-bit Windows): set WinSdk71=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A - set SDK_INCLUDE_DIR=%WinSdk71%\Include set INCLUDE=%WinSdk71%\Include;%INCLUDE% set LIB=%WinSdk71%\Lib;%LIB% - set PATH=%WinSdk71%\Bin;%PATH% set CL=/D_USING_V110_SDK71_ nmake -f Make_mvc.mak ... WINVER=0x0501 SUBSYSTEM_VER=5.01 +To target Windows XP x64 instead of x86, you need to change the settings of +LIB and SUBSYSTEM_VER: + ... + set LIB=%WinSdk71%\Lib\x64;%LIB% + ... + nmake -f Make_mvc.mak ... WINVER=0x0501 SUBSYSTEM_VER=5.02 + +If you use Visual C++ 2015 (either Express or Community Edition), executing +msvc2015.bat will set them automatically. For x86 builds run this without +options: + msvc2015 +For x64 builds run this with the "x86_amd64" option: + msvc2015 x86_amd64 + The following Visual C++ team blog can serve as a reference page: http://blogs.msdn.com/b/vcblog/archive/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012.aspx @@ -188,10 +210,10 @@ Now you can build Vim with Make_mvc.mak. Getting the Windows Platform SDK *ms-platform-sdk* -You will also need a copy of the Windows Platform SDK from - http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ -Specifically, you need the Windows Core SDK subset of the Platform SDK, -which contains the Windows headers and libraries. +You will also need a copy of the Windows Platform SDK. Specifically, you need +the Windows Core SDK subset of the Platform SDK, which contains the Windows +headers and libraries. You need to search for it, Microsoft keeps changing +the URL. Getting the .NET Framework 1.1 Runtime *dotnet-1.1-redist* @@ -432,10 +454,61 @@ E.g. When using MSVC (as one line): PYTHON3=C:\Python34 DYNAMIC_PYTHON3=yes PYTHON3_VER=34 -8. Building with MzScheme/Racket support +8. Building with Racket or MzScheme support ======================================== -1) Building with MzScheme support +1) Building with Racket support (newest) + +MzScheme and PLT Scheme names have been rebranded as Racket. Vim with Racket +support can be built with either MSVC or MinGW (or Cygwin). +Get it from https://download.racket-lang.org/ + +Copy lib/libracket{version}.dll to your Windows system directory. The system +directory depends on your Windows bitness and Vim bitness: + 32-bit Vim on 32-bit Windows: C:\Windows\System32 + 32-bit Vim on 64-bit Windows: C:\Windows\SysWOW64 + 64-bit Vim on 64-bit Windows: C:\Windows\System32 + +For building you need to set the following variables: + + MZSCHEME: Where Racket is installed. + E.g. C:\Program Files (x86)\Racket + DYNAMIC_MZSCHEME: Whether dynamic linking is used. Usually, set to yes. + MZSCHEME_VER: Racket DLL version which is used for the file name. + See below for a list of MZSCHEME_VER. + The DLL can be found under the lib directory. E.g. + C:\Program Files (x86)\Racket\lib\libracket3m_XXXXXX.dll + MZSCHEME_COLLECTS: (Optional) Path of the collects directory used at + runtime. Default: $(MZSCHEME)\collects + User can override this with the PLTCOLLECTS environment + variable. + +List of MZSCHEME_VER (incomplete): + + Racket ver. | MZSCHEME_VER + ========================== + 6.3 | 3m_9z0ds0 + 6.6 | 3m_a0solc + 6.8 | 3m_a1zjsw + 6.10 | 3m_a36fs8 + + +E.g. When using MSVC (as one line): + + nmake -f Make_mvc.mak + MZSCHEME="C:\Program Files (x86)\Racket" DYNAMIC_MZSCHEME=yes + MZSCHEME_VER=3m_9z0ds0 + +Or when using MinGW (as one line): + + mingw32-make -f Make_ming.mak + MZSCHEME='C:/Program\ Files\ (x86)/Racket' DYNAMIC_MZSCHEME=yes + MZSCHEME_VER=3m_9z0ds0 + + Spaces should be escaped with '\'. + + +2) Building with MzScheme support (older) (written by Sergey Khorev ) @@ -470,40 +543,6 @@ After a successful build, these dlls can be freely removed, leaving them in %WINDOWS%\System32 only. -2) Building with Racket support - -MzScheme and PLT Scheme names have been rebranded as Racket. Vim with Racket -(https://racket-lang.org/) support can be built with either MSVC or MinGW (or -Cygwin). - -You need to set the following variables: - - MZSCHEME: Where Racket is installed. - E.g. C:\Program Files (x86)\Racket - DYNAMIC_MZSCHEME: Whether dynamic linking is used. Usually, set to yes. - MZSCHEME_VER: Racket DLL version which is used for the file name. - E.g. 3m_9z0ds0 for Racket 6.3. - The DLL can be found under the lib directory. E.g. - C:\Program Files (x86)\Racket\lib\libracket3m_XXXXXX.dll - MZSCHEME_COLLECTS: (Optional) Path of the collects directory used at - runtime. Default: $(MZSCHEME)\collects - User can override this with the PLTCOLLECTS environment - variable. - -E.g. When using MSVC (as one line): - - nmake -f Make_mvc.mak - MZSCHEME="C:\Program Files (x86)\Racket" DYNAMIC_MZSCHEME=yes - MZSCHEME_VER=3m_9z0ds0 - -Or when using MinGW (as one line): - - mingw32-make -f Make_ming.mak - MZSCHEME='C:/Program\ Files\ (x86)/Racket' DYNAMIC_MZSCHEME=yes - MZSCHEME_VER=3m_9z0ds0 - - Spaces should be escaped with '\'. - 9. Building with Lua support ============================ @@ -550,7 +589,7 @@ E.g. When using MSVC (as one line): Or when using MinGW (as one line): - mingw32-make -f Make_mingw.mak + mingw32-make -f Make_ming.mak LUA=C:\projects\lua53 DYNAMIC_LUA=yes LUA_VER=53 @@ -582,7 +621,7 @@ E.g. When using MSVC (as one line): Or when using MinGW (as one line): - mingw32-make -f Make_mingw.mak + mingw32-make -f Make_ming.mak PERL=C:\Perl DYNAMIC_PERL=yes PERL_VER=522 @@ -591,7 +630,7 @@ Or when using MinGW (as one line): Vim with Ruby support can be built with either MSVC or MinGW (or Cygwin). Ruby doesn't provide the official Windows binaries. The most widely used -Windows binaries might be RubyInstaller. +Windows binaries might be RubyInstaller. Currently Ruby 2.4 is recommended. http://rubyinstaller.org/ @@ -602,11 +641,11 @@ you need some tricks described below. When building, you need to set the following variables at least: - RUBY: Where ruby is installed. E.g. C:\Ruby22 + RUBY: Where ruby is installed. E.g. C:\Ruby24 DYNAMIC_RUBY: Whether dynamic linking is used. Usually, set to yes. - RUBY_VER: Ruby version. E.g. 22 for Ruby 2.2.X. + RUBY_VER: Ruby version. E.g. 24 for Ruby 2.4.X. RUBY_API_VER_LONG: Ruby API version in a long format. - E.g. 2.2.0 for Ruby 2.2.X. + E.g. 2.4.0 for Ruby 2.4.X. Ruby version vs. Ruby API version: @@ -631,33 +670,34 @@ config.h and Ruby's DLL name. Here are the steps for working around them: 1) Download and Install RubyInstaller. You can install RubyInstaller with the default options and directory. E.g.: - C:\Ruby22 (32-bit) or C:\Ruby22-x64 (64-bit) + C:\Ruby24 (32-bit) or C:\Ruby24-x64 (64-bit) - Ruby 2.2.X is used in this example. + Ruby 2.4.X is used in this example. - 2) Download Ruby 2.2.X's source code and generate config.h: + 2) Download Ruby 2.4.X's source code and generate config.h: cd C:\projects - git clone https://github.com/ruby/ruby.git -b ruby_2_2 + git clone https://github.com/ruby/ruby.git -b ruby_2_4 cd ruby win32\configure.bat nmake .config.h.time - Note that ruby_2_2 is the branch name for Ruby 2.2.X's source code. + Note that ruby_2_4 is the branch name for Ruby 2.4.X's source code. There is no need to build whole Ruby, just config.h is needed. If you use 32-bit MSVC10, the config.h is generated in the - .ext\include\i386-mswin32_100 directory. + .ext\include\i386-mswin32_140 directory. 3) Install the generated config.h. - xcopy /s .ext\include C:\Ruby22\include\ruby-2.2.0 + xcopy /s .ext\include E:\Ruby24\include\ruby-2.4.0 - Note that 2.2.0 is Ruby API version of Ruby 2.2.X. + Note that 2.4.0 is Ruby API version of Ruby 2.4.X. + You may need to close the console and reopen it to pick up the new $PATH. 4) Build Vim. Note that you need to adjust some variables (as one line): nmake -f Make_mvc.mak - RUBY=C:\Ruby22 DYNAMIC_RUBY=yes RUBY_VER=22 RUBY_API_VER_LONG=2.2.0 + RUBY=C:\Ruby24 DYNAMIC_RUBY=yes RUBY_VER=24 RUBY_API_VER_LONG=2.4.0 RUBY_MSVCRT_NAME=msvcrt WINVER=0x501 @@ -688,6 +728,7 @@ You can use binaries from ActiveState (ActiveTcl). http://www.activestate.com/activetcl +For MSVC 2015 use version 8.6.6 or later. When building, you need to set the following variables: TCL: Where tcl is installed. E.g. C:\Tcl86 @@ -695,6 +736,11 @@ When building, you need to set the following variables: TCL_VER: Tcl version in a short format. E.g. 86 for Tcl 8.6.X. TCL_VER_LONG: Tcl version in a long format. E.g. 8.6 for Tcl 8.6.X. +Sometimes the Tcl dll name changes. E.g. ActiveTcl 8.6.4 comes with tcl86.dll, +but ActiveTcl 8.6.6 comes with tcl86t.dll. You can set the dll name by setting +the TCL_DLL variable: + TCL_DLL=tcl86t.dll + E.g. When using MSVC (as one line): nmake -f Make_mvc.mak @@ -702,7 +748,7 @@ E.g. When using MSVC (as one line): Or when using MinGW (as one line): - mingw32-make -f Make_mingw.mak + mingw32-make -f Make_ming.mak TCL=C:\Tcl86 DYNAMIC_TCL=yes TCL_VER=86 TCL_VER_LONG=8.6 @@ -719,7 +765,7 @@ E.g. When using MSVC: Or when using MinGW (as one line): - mingw32-make -f Make_mingw.mak TERMINAL=yes + mingw32-make -f Make_ming.mak TERMINAL=yes 14. Windows 3.1x diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak index a855f066e5..87de4e9a09 100644 --- a/src/Make_cyg_ming.mak +++ b/src/Make_cyg_ming.mak @@ -47,6 +47,7 @@ FEATURES=HUGE # Set to yes to cross-compile from unix; no=native Windows (and Cygwin). CROSS=no # Set to path to iconv.h and libiconv.a to enable using 'iconv.dll'. +# Use "yes" when the path does not need to be define. #ICONV="." ICONV=yes GETTEXT=yes @@ -74,7 +75,11 @@ else CHANNEL=$(GUI) endif # Set to yes to enable terminal support. +ifeq (HUGE, $(FEATURES)) +TERMINAL=yes +else TERMINAL=no +endif ifndef CTAGS # this assumes ctags is Exuberant ctags diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index e9ba1c5c07..30a52f4b9c 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -37,7 +37,7 @@ # is yes) # Global IME support: GIME=yes (requires GUI=yes) # -# Terminal support: TERMINAL=yes (default is no) +# Terminal support: TERMINAL=yes (default is yes) # # Lua interface: # LUA=[Path to Lua directory] @@ -361,6 +361,14 @@ CSCOPE_OBJ = $(OBJDIR)/if_cscope.obj CSCOPE_DEFS = -DFEAT_CSCOPE !endif +!ifndef TERMINAL +!if "$(FEATURES)"=="HUGE" +TERMINAL = yes +!else +TERMINAL = no +!endif +!endif + !if "$(TERMINAL)" == "yes" TERM_OBJ = \ $(OBJDIR)/terminal.obj \ @@ -587,7 +595,7 @@ CPUARG = /arch:AVX2 ! endif !endif -# Pass CPUARG to GVimExt, to avoid using version-dependent defaults +# Pass CPUARG to GvimExt, to avoid using version-dependent defaults MAKEFLAGS_GVIMEXT = $(MAKEFLAGS_GVIMEXT) CPUARG="$(CPUARG)" @@ -789,9 +797,14 @@ SUBSYSTEM = console CUI_INCL = iscygpty.h CUI_OBJ = $(OUTDIR)\iscygpty.obj !endif +SUBSYSTEM_TOOLS = console !if "$(SUBSYSTEM_VER)" != "" SUBSYSTEM = $(SUBSYSTEM),$(SUBSYSTEM_VER) +SUBSYSTEM_TOOLS = $(SUBSYSTEM_TOOLS),$(SUBSYSTEM_VER) +# Pass SUBSYSTEM_VER to GvimExt and other tools +MAKEFLAGS_GVIMEXT = $(MAKEFLAGS_GVIMEXT) SUBSYSTEM_VER=$(SUBSYSTEM_VER) +MAKEFLAGS_TOOLS = $(MAKEFLAGS_TOOLS) SUBSYSTEM_VER=$(SUBSYSTEM_VER) !endif !if "$(GUI)" == "yes" && "$(DIRECTX)" == "yes" @@ -1186,24 +1199,26 @@ $(OUTDIR): install.exe: dosinst.c $(CC) /nologo -DNDEBUG -DWIN32 dosinst.c kernel32.lib shell32.lib \ - user32.lib ole32.lib advapi32.lib uuid.lib + user32.lib ole32.lib advapi32.lib uuid.lib \ + -link -subsystem:$(SUBSYSTEM_TOOLS) - if exist install.exe del install.exe ren dosinst.exe install.exe uninstal.exe: uninstal.c - $(CC) /nologo -DNDEBUG -DWIN32 uninstal.c shell32.lib advapi32.lib + $(CC) /nologo -DNDEBUG -DWIN32 uninstal.c shell32.lib advapi32.lib \ + -link -subsystem:$(SUBSYSTEM_TOOLS) vimrun.exe: vimrun.c - $(CC) /nologo -DNDEBUG vimrun.c + $(CC) /nologo -DNDEBUG vimrun.c -link -subsystem:$(SUBSYSTEM_TOOLS) xxd/xxd.exe: xxd/xxd.c cd xxd - $(MAKE) /NOLOGO -f Make_mvc.mak + $(MAKE) /NOLOGO -f Make_mvc.mak $(MAKEFLAGS_TOOLS) cd .. tee/tee.exe: tee/tee.c cd tee - $(MAKE) /NOLOGO -f Make_mvc.mak + $(MAKE) /NOLOGO -f Make_mvc.mak $(MAKEFLAGS_TOOLS) cd .. GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h diff --git a/src/Makefile b/src/Makefile index 837610ff45..2341b0dbf9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2117,14 +2117,14 @@ test1 \ test_listchars \ test_search_mbyte \ test_wordcount \ - test3 test4 test5 test7 test8 \ + test3 test8 \ test11 test12 test14 test15 test17 test19 \ test20 test25 test28 test29 \ - test30 test31 test32 test34 test36 test37 test38 test39 \ + test30 test32 test34 test36 test37 test38 test39 \ test40 test42 test44 test45 test48 test49 \ test50 test52 test54 test55 test59 \ - test60 test64 test66 test68 test69 \ - test70 test72 test73 test77 test78 test79 \ + test64 test66 test68 test69 \ + test70 test72 test73 test77 test79 \ test83 test85 test86 test87 test88 \ test94 test95 test99 \ test108: @@ -2166,6 +2166,7 @@ test_arglist \ test_ex_z \ test_exec_while_if \ test_execute_func \ + test_exists \ test_exists_autocmd \ test_expand \ test_expand_dllpath \ @@ -2296,6 +2297,7 @@ test_arglist \ test_virtualedit \ test_visual \ test_winbar \ + test_winbuf_close \ test_window_cmd \ test_window_id \ test_windows_home \ diff --git a/src/auto/configure b/src/auto/configure index 68335b38fa..0f7315745f 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -7284,10 +7284,10 @@ $as_echo "$rubyhdrdir" >&6; } $as_echo "#define FEAT_RUBY 1" >>confdefs.h if test "$enable_rubyinterp" = "dynamic"; then - libruby=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG['LIBRUBY_SO']"` + libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG['LIBRUBY_ALIASES'].split[0]"` $as_echo "#define DYNAMIC_RUBY 1" >>confdefs.h - RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" + RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" RUBY_LIBS= fi else diff --git a/src/bigvim.bat b/src/bigvim.bat index 804bd860e0..da7e1210b3 100644 --- a/src/bigvim.bat +++ b/src/bigvim.bat @@ -1,5 +1,5 @@ -:: command to build big Vim with OLE, Perl, Python, Ruby and Tcl +:: command to build big Vim with OLE, Lua, Perl, Python, Racket, Ruby and Tcl SET VCDIR="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\" SET TOOLDIR=E:\ -%VCDIR%nmake -f Make_mvc.mak GUI=yes OLE=yes PERL=%TOOLDIR%perl524 DYNAMIC_PERL=yes PERL_VER=524 PYTHON=%TOOLDIR%python27 DYNAMIC_PYTHON=yes PYTHON_VER=27 PYTHON3=%TOOLDIR%python35 DYNAMIC_PYTHON3=yes PYTHON3_VER=35 RUBY=%TOOLDIR%ruby22 DYNAMIC_RUBY=yes RUBY_VER=22 RUBY_API_VER_LONG=2.2.0 RUBY_MSVCRT_NAME=msvcrt TCL=%TOOLDIR%tcl TCL_VER=86 TCL_VER_LONG=8.6 DYNAMIC_TCL=yes %1 IME=yes CSCOPE=yes DIRECTX=yes +%VCDIR%nmake -f Make_mvc.mak GUI=yes OLE=yes LUA=%TOOLDIR%lua53 DYNAMIC_LUA=yes LUA_VER=53 PERL=%TOOLDIR%perl524 DYNAMIC_PERL=yes PERL_VER=524 PYTHON=%TOOLDIR%python27 DYNAMIC_PYTHON=yes PYTHON_VER=27 PYTHON3=%TOOLDIR%python35 DYNAMIC_PYTHON3=yes PYTHON3_VER=35 MZSCHEME=%TOOLDIR%Racket DYNAMIC_MZSCHEME=yes MZSCHEME_VER=3m_a36fs8 RUBY=%TOOLDIR%ruby24 DYNAMIC_RUBY=yes RUBY_VER=24 RUBY_API_VER_LONG=2.4.0 RUBY_MSVCRT_NAME=msvcrt TCL=%TOOLDIR%ActiveTcl TCL_VER=86 TCL_VER_LONG=8.6 DYNAMIC_TCL=yes TCL_DLL=tcl86t.dll %1 IME=yes CSCOPE=yes DIRECTX=yes diff --git a/src/buffer.c b/src/buffer.c index 6ddd6c16db..65391ba862 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -841,6 +841,8 @@ free_buffer(buf_T *buf) ++buf_free_count; free_buffer_stuff(buf, TRUE); #ifdef FEAT_EVAL + /* b:changedtick uses an item in buf_T, remove it now */ + dictitem_remove(buf->b_vars, (dictitem_T *)&buf->b_ct_di); unref_var_dict(buf->b_vars); #endif #ifdef FEAT_LUA diff --git a/src/configure.ac b/src/configure.ac index 85ba824079..8c7f72a2bd 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -1966,9 +1966,9 @@ if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then AC_DEFINE(FEAT_RUBY) if test "$enable_rubyinterp" = "dynamic"; then - libruby=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"` + libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"` AC_DEFINE(DYNAMIC_RUBY) - RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" + RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" RUBY_LIBS= fi else diff --git a/src/dosinst.c b/src/dosinst.c index 05398be37d..bb95bd86ab 100644 --- a/src/dosinst.c +++ b/src/dosinst.c @@ -19,6 +19,9 @@ #define DOSINST #include "dosinst.h" +#define GVIMEXT64_PATH "GvimExt64\\gvimext.dll" +#define GVIMEXT32_PATH "GvimExt32\\gvimext.dll" + /* Macro to do an error check I was typing over and over */ #define CHECK_REG_ERROR(code) if (code != ERROR_SUCCESS) { printf("%ld error number: %ld\n", (long)__LINE__, (long)code); return 1; } @@ -75,7 +78,7 @@ char *(remap_choices[]) = { "\nChoose:", "Do not remap keys for Windows behavior", - "Remap a few keys for Windows behavior (, , etc)", + "Remap a few keys for Windows behavior (CTRL-V, CTRL-C, CTRL-F, etc)", }; int remap_choice = (int)remap_win; char *remap_text = "- %s"; @@ -359,7 +362,6 @@ find_bat_exe(int check_bat_only) mch_chdir(installdir); } -#ifdef WIN3264 /* * Get the value of $VIMRUNTIME or $VIM and write it in $TEMP/vimini.ini, so * that NSIS can read it. @@ -612,7 +614,6 @@ uninstall_check(int skip_question) return foundone; } -#endif /* * Find out information about the system. @@ -1324,12 +1325,12 @@ init_vimrc_choices(void) ++choice_count; } -#if defined(WIN3264) static LONG reg_create_key( HKEY root, const char *subkey, - PHKEY phKey) + PHKEY phKey, + DWORD flag) { DWORD disp; @@ -1337,7 +1338,7 @@ reg_create_key( return RegCreateKeyEx( root, subkey, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_WOW64_64KEY | KEY_WRITE, + flag | KEY_WRITE, NULL, phKey, &disp); } @@ -1356,10 +1357,11 @@ reg_create_key_and_value( HKEY hRootKey, const char *subkey, const char *value_name, - const char *data) + const char *data, + DWORD flag) { HKEY hKey; - LONG lRet = reg_create_key(hRootKey, subkey, &hKey); + LONG lRet = reg_create_key(hRootKey, subkey, &hKey, flag); if (ERROR_SUCCESS == lRet) { @@ -1375,21 +1377,22 @@ register_inproc_server( const char *clsid, const char *extname, const char *module, - const char *threading_model) + const char *threading_model, + DWORD flag) { CHAR subkey[BUFSIZE]; LONG lRet; sprintf(subkey, "CLSID\\%s", clsid); - lRet = reg_create_key_and_value(hRootKey, subkey, NULL, extname); + lRet = reg_create_key_and_value(hRootKey, subkey, NULL, extname, flag); if (ERROR_SUCCESS == lRet) { sprintf(subkey, "CLSID\\%s\\InProcServer32", clsid); - lRet = reg_create_key_and_value(hRootKey, subkey, NULL, module); + lRet = reg_create_key_and_value(hRootKey, subkey, NULL, module, flag); if (ERROR_SUCCESS == lRet) { lRet = reg_create_key_and_value(hRootKey, subkey, - "ThreadingModel", threading_model); + "ThreadingModel", threading_model, flag); } } return lRet; @@ -1400,13 +1403,15 @@ register_shellex( HKEY hRootKey, const char *clsid, const char *name, - const char *exe_path) + const char *exe_path, + DWORD flag) { LONG lRet = reg_create_key_and_value( hRootKey, "*\\shellex\\ContextMenuHandlers\\gvim", NULL, - clsid); + clsid, + flag); if (ERROR_SUCCESS == lRet) { @@ -1414,7 +1419,8 @@ register_shellex( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", clsid, - name); + name, + flag); if (ERROR_SUCCESS == lRet) { @@ -1422,7 +1428,8 @@ register_shellex( HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", "path", - exe_path); + exe_path, + flag); } } return lRet; @@ -1431,7 +1438,8 @@ register_shellex( static LONG register_openwith( HKEY hRootKey, - const char *exe_path) + const char *exe_path, + DWORD flag) { char exe_cmd[BUFSIZE]; LONG lRet; @@ -1441,7 +1449,8 @@ register_openwith( hRootKey, "Applications\\gvim.exe\\shell\\edit\\command", NULL, - exe_cmd); + exe_cmd, + flag); if (ERROR_SUCCESS == lRet) { @@ -1455,7 +1464,7 @@ register_openwith( for (i = 0; ERROR_SUCCESS == lRet && i < sizeof(openwith) / sizeof(openwith[0]); i++) { - lRet = reg_create_key_and_value(hRootKey, openwith[i], NULL, ""); + lRet = reg_create_key_and_value(hRootKey, openwith[i], NULL, "", flag); } } @@ -1470,14 +1479,13 @@ register_uninstall( const char *uninstall_string) { LONG lRet = reg_create_key_and_value(hRootKey, appname, - "DisplayName", display_name); + "DisplayName", display_name, KEY_WOW64_64KEY); if (ERROR_SUCCESS == lRet) lRet = reg_create_key_and_value(hRootKey, appname, - "UninstallString", uninstall_string); + "UninstallString", uninstall_string, KEY_WOW64_64KEY); return lRet; } -#endif /* WIN3264 */ /* * Add some entries to the registry: @@ -1489,7 +1497,6 @@ register_uninstall( static int install_registry(void) { -#ifdef WIN3264 LONG lRet = ERROR_SUCCESS; const char *vim_ext_ThreadingModel = "Apartment"; const char *vim_ext_name = "Vim Shell Extension"; @@ -1497,40 +1504,59 @@ install_registry(void) char vim_exe_path[BUFSIZE]; char display_name[BUFSIZE]; char uninstall_string[BUFSIZE]; + int i; + int loop_count = is_64bit_os() ? 2 : 1; + DWORD flag; sprintf(vim_exe_path, "%s\\gvim.exe", installdir); if (install_popup) { char bufg[BUFSIZE]; - struct stat st; - - if (stat("gvimext.dll", &st) >= 0) - sprintf(bufg, "%s\\gvimext.dll", installdir); - else - /* gvimext.dll is in gvimext subdir */ - sprintf(bufg, "%s\\gvimext\\gvimext.dll", installdir); printf("Creating \"Edit with Vim\" popup menu entry\n"); - lRet = register_inproc_server( - HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, - bufg, vim_ext_ThreadingModel); - if (ERROR_SUCCESS != lRet) - return FAIL; - lRet = register_shellex( - HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, vim_exe_path); - if (ERROR_SUCCESS != lRet) - return FAIL; + for (i = 0; i < loop_count; i++) + { + if (i == 0) + { + sprintf(bufg, "%s\\" GVIMEXT32_PATH, installdir); + flag = KEY_WOW64_32KEY; + } + else + { + sprintf(bufg, "%s\\" GVIMEXT64_PATH, installdir); + flag = KEY_WOW64_64KEY; + } + + lRet = register_inproc_server( + HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, + bufg, vim_ext_ThreadingModel, flag); + if (ERROR_SUCCESS != lRet) + return FAIL; + lRet = register_shellex( + HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, + vim_exe_path, flag); + if (ERROR_SUCCESS != lRet) + return FAIL; + } } if (install_openwith) { printf("Creating \"Open with ...\" list entry\n"); - lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path); - if (ERROR_SUCCESS != lRet) - return FAIL; + for (i = 0; i < loop_count; i++) + { + if (i == 0) + flag = KEY_WOW64_32KEY; + else + flag = KEY_WOW64_64KEY; + + lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path, flag); + if (ERROR_SUCCESS != lRet) + return FAIL; + } } printf("Creating an uninstall entry\n"); @@ -1554,7 +1580,6 @@ install_registry(void) uninstall_string); if (ERROR_SUCCESS != lRet) return FAIL; -#endif /* WIN3264 */ return OK; } @@ -1584,12 +1609,8 @@ init_popup_choice(void) struct stat st; if (has_gvim - && (stat("gvimext.dll", &st) >= 0 - || stat("gvimext/gvimext.dll", &st) >= 0) -#ifndef WIN3264 - && searchpath("regedit.exe") != NULL -#endif - ) + && (stat(GVIMEXT32_PATH, &st) >= 0 + || stat(GVIMEXT64_PATH, &st) >= 0)) { choices[choice_count].changefunc = change_popup_choice; choices[choice_count].installfunc = NULL; @@ -1623,11 +1644,7 @@ change_openwith_choice(int idx) static void init_openwith_choice(void) { - if (has_gvim -#ifndef WIN3264 - && searchpath("regedit.exe") != NULL -#endif - ) + if (has_gvim) { choices[choice_count].changefunc = change_openwith_choice; choices[choice_count].installfunc = NULL; @@ -1639,7 +1656,6 @@ init_openwith_choice(void) add_dummy_choice(); } -#ifdef WIN3264 /* create_shortcut * * Create a shell link. @@ -1935,21 +1951,16 @@ toggle_shortcut_choice(int idx) alloc_text(idx, "Create a desktop icon for %s", arg); } } -#endif /* WIN3264 */ static void init_startmenu_choice(void) { -#ifdef WIN3264 /* Start menu */ choices[choice_count].changefunc = toggle_startmenu_choice; choices[choice_count].installfunc = NULL; choices[choice_count].active = 1; toggle_startmenu_choice(choice_count); /* set the text */ ++choice_count; -#else - add_dummy_choice(); -#endif } /* @@ -1958,7 +1969,6 @@ init_startmenu_choice(void) static void init_shortcut_choices(void) { -#ifdef WIN3264 /* Shortcut to gvim */ choices[choice_count].text = NULL; choices[choice_count].arg = 0; @@ -1985,14 +1995,8 @@ init_shortcut_choices(void) choices[choice_count].installfunc = install_shortcut_gview; toggle_shortcut_choice(choice_count); ++choice_count; -#else - add_dummy_choice(); - add_dummy_choice(); - add_dummy_choice(); -#endif } -#ifdef WIN3264 /* * Attempt to register OLE for Vim. */ @@ -2004,16 +2008,9 @@ install_OLE_register(void) printf("\n--- Attempting to register Vim with OLE ---\n"); printf("(There is no message whether this works or not.)\n"); -#ifndef __CYGWIN__ sprintf(register_command_string, "\"%s\\gvim.exe\" -silent -register", installdir); -#else - /* handle this differently for Cygwin which sometimes has trouble with - * Windows-style pathnames here. */ - sprintf(register_command_string, "./gvim.exe -silent -register"); -#endif system(register_command_string); } -#endif /* WIN3264 */ /* * Remove the last part of directory "path[]" to get its parent, and put the @@ -2212,19 +2209,15 @@ print_cmd_line_help(void) printf(" Install the Edit-with-Vim context menu entry\n"); printf("-install-openwith\n"); printf(" Add Vim to the \"Open With...\" context menu list\n"); -#ifdef WIN3264 printf("-add-start-menu"); printf(" Add Vim to the start menu\n"); printf("-install-icons"); printf(" Create icons for gVim executables on the desktop\n"); -#endif printf("-create-directories [vim|home]\n"); printf(" Create runtime directories to drop plugins into; in the $VIM\n"); printf(" or $HOME directory\n"); -#ifdef WIN3264 printf("-register-OLE"); printf(" Ignored\n"); -#endif printf("\n"); } @@ -2308,12 +2301,10 @@ command_line_setup_choices(int argc, char **argv) else /* No choice specified, default to vim directory */ vimfiles_dir_choice = (int)vimfiles_dir_vim; } -#ifdef WIN3264 else if (strcmp(argv[i], "-register-OLE") == 0) { /* This is always done when gvim is found */ } -#endif else /* Unknown switch */ { printf("Got unknown argument argv[%d] = %s\n", i, argv[i]); @@ -2471,11 +2462,9 @@ install(void) || !interactive) install_registry(); -#ifdef WIN3264 /* Register gvim with OLE. */ if (has_gvim) install_OLE_register(); -#endif } /* @@ -2511,7 +2500,6 @@ main(int argc, char **argv) /* Initialize this program. */ do_inits(argv); -#ifdef WIN3264 if (argc > 1 && strcmp(argv[1], "-uninstall-check") == 0) { /* Only check for already installed Vims. Used by NSIS installer. */ @@ -2527,7 +2515,6 @@ main(int argc, char **argv) sleep(3); exit(0); } -#endif printf("This program sets up the installation of Vim " VIM_VERSION_MEDIUM "\n\n"); @@ -2535,11 +2522,9 @@ main(int argc, char **argv) /* Check if the user unpacked the archives properly. */ check_unpack(); -#ifdef WIN3264 /* Check for already installed Vims. */ if (interactive) uninstall_check(0); -#endif /* Find out information about the system. */ inspect_system(); diff --git a/src/dosinst.h b/src/dosinst.h index 268a91ba44..59de932489 100644 --- a/src/dosinst.h +++ b/src/dosinst.h @@ -26,19 +26,10 @@ # include "vimio.h" # include -# ifndef __CYGWIN__ -# include -# endif +# include -# if defined(_WIN64) || defined(WIN32) -# define WIN3264 -# include -# include -# else -# include -# include -# include -# endif +# include +# include #endif #ifdef UNIX_LINT @@ -56,7 +47,7 @@ char *searchpath(char *name); #if defined(UNIX_LINT) # define vim_mkdir(x, y) mkdir((char *)(x), y) #else -# if defined(WIN3264) && !defined(__BORLANDC__) +# ifndef __BORLANDC__ # define vim_mkdir(x, y) _mkdir((char *)(x)) # else # define vim_mkdir(x, y) mkdir((char *)(x)) @@ -88,6 +79,9 @@ char *searchpath(char *name); # ifndef KEY_WOW64_64KEY # define KEY_WOW64_64KEY 0x0100 # endif +# ifndef KEY_WOW64_32KEY +# define KEY_WOW64_32KEY 0x0200 +# endif #define VIM_STARTMENU "Programs\\Vim " VIM_VERSION_SHORT @@ -134,40 +128,32 @@ myexit(int n) exit(n); } -#ifdef WIN3264 -/* This symbol is not defined in older versions of the SDK or Visual C++ */ - -#ifndef VER_PLATFORM_WIN32_WINDOWS -# define VER_PLATFORM_WIN32_WINDOWS 1 -#endif - -static DWORD g_PlatformId; +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL); /* - * Set g_PlatformId to VER_PLATFORM_WIN32_NT (NT) or - * VER_PLATFORM_WIN32_WINDOWS (Win95). + * Check if this is a 64-bit OS. */ - static void -PlatformId(void) + static BOOL +is_64bit_os(void) { - static int done = FALSE; +#ifdef _WIN64 + return TRUE; +#else + BOOL bIsWow64 = FALSE; + LPFN_ISWOW64PROCESS pIsWow64Process; - if (!done) - { - OSVERSIONINFO ovi; - - ovi.dwOSVersionInfoSize = sizeof(ovi); - GetVersionEx(&ovi); - - g_PlatformId = ovi.dwPlatformId; - done = TRUE; - } + pIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( + GetModuleHandle("kernel32"), "IsWow64Process"); + if (pIsWow64Process != NULL) + pIsWow64Process(GetCurrentProcess(), &bIsWow64); + return bIsWow64; +#endif } -# ifdef __BORLANDC__ +#ifdef __BORLANDC__ /* Borland defines its own searchpath() in dir.h */ -# include -# else +# include +#else static char * searchpath(char *name) { @@ -176,28 +162,17 @@ searchpath(char *name) /* There appears to be a bug in FindExecutableA() on Windows NT. * Use FindExecutableW() instead... */ - PlatformId(); - if (g_PlatformId == VER_PLATFORM_WIN32_NT) + MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)name, -1, + (LPWSTR)widename, BUFSIZE); + if (FindExecutableW((LPCWSTR)widename, (LPCWSTR)"", + (LPWSTR)location) > (HINSTANCE)32) { - MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)name, -1, - (LPWSTR)widename, BUFSIZE); - if (FindExecutableW((LPCWSTR)widename, (LPCWSTR)"", - (LPWSTR)location) > (HINSTANCE)32) - { - WideCharToMultiByte(CP_ACP, 0, (LPWSTR)location, -1, - (LPSTR)widename, 2 * BUFSIZE, NULL, NULL); - return widename; - } - } - else - { - if (FindExecutableA((LPCTSTR)name, (LPCTSTR)"", - (LPTSTR)location) > (HINSTANCE)32) - return location; + WideCharToMultiByte(CP_ACP, 0, (LPWSTR)location, -1, + (LPSTR)widename, 2 * BUFSIZE, NULL, NULL); + return widename; } return NULL; } -# endif #endif /* @@ -217,7 +192,6 @@ searchpath_save(char *name) return s; } -#ifdef WIN3264 #ifndef CSIDL_COMMON_PROGRAMS # define CSIDL_COMMON_PROGRAMS 0x0017 @@ -355,7 +329,6 @@ retry: return OK; } -#endif /* * List of targets. The first one (index zero) is used for the default path @@ -406,10 +379,8 @@ char *(icon_link_names[ICON_COUNT]) = "gVim Easy " VIM_VERSION_SHORT ".lnk", "gVim Read only " VIM_VERSION_SHORT ".lnk"}; -/* This is only used for dosinst.c when WIN3264 is defined and for uninstal.c - * when not being able to directly access registry entries. */ -#if (defined(DOSINST) && defined(WIN3264)) \ - || (!defined(DOSINST) && !defined(WIN3264)) +/* This is only used for dosinst.c. */ +#if defined(DOSINST) /* * Run an external command and wait for it to finish. */ @@ -464,24 +435,9 @@ add_pathsep(char *name) int change_drive(int drive) { -#ifdef WIN3264 char temp[3] = "-:"; temp[0] = (char)(drive + 'A' - 1); return !SetCurrentDirectory(temp); -#else -# ifndef UNIX_LINT - union REGS regs; - - regs.h.ah = 0x0e; - regs.h.dl = drive - 1; - intdos(®s, ®s); /* set default drive */ - regs.h.ah = 0x19; - intdos(®s, ®s); /* get default drive */ - if (regs.h.al == drive - 1) - return 0; -# endif - return -1; -#endif } /* @@ -507,7 +463,7 @@ mch_chdir(char *path) /* * Expand the executable name into a full path name. */ -#if defined(__BORLANDC__) && !defined(WIN3264) +#if defined(__BORLANDC__) /* Only Borland C++ has this. */ # define my_fullpath(b, n, l) _fullpath(b, n, l) @@ -516,92 +472,11 @@ mch_chdir(char *path) static char * my_fullpath(char *buf, char *fname, int len) { -# ifdef WIN3264 /* Only GetModuleFileName() will get the long file name path. * GetFullPathName() may still use the short (FAT) name. */ DWORD len_read = GetModuleFileName(NULL, buf, (size_t)len); return (len_read > 0 && len_read < (DWORD)len) ? buf : NULL; -# else - char olddir[BUFSIZE]; - char *p, *q; - int c; - char *retval = buf; - - if (strchr(fname, ':') != NULL) /* already expanded */ - { - strncpy(buf, fname, len); - } - else - { - *buf = NUL; - /* - * change to the directory for a moment, - * and then do the getwd() (and get back to where we were). - * This will get the correct path name with "../" things. - */ - p = strrchr(fname, '/'); - q = strrchr(fname, '\\'); - if (q != NULL && (p == NULL || q > p)) - p = q; - q = strrchr(fname, ':'); - if (q != NULL && (p == NULL || q > p)) - p = q; - if (p != NULL) - { - if (getcwd(olddir, BUFSIZE) == NULL) - { - p = NULL; /* can't get current dir: don't chdir */ - retval = NULL; - } - else - { - if (p == fname) /* /fname */ - q = p + 1; /* -> / */ - else if (q + 1 == p) /* ... c:\foo */ - q = p + 1; /* -> c:\ */ - else /* but c:\foo\bar */ - q = p; /* -> c:\foo */ - - c = *q; /* truncate at start of fname */ - *q = NUL; - if (mch_chdir(fname)) /* change to the directory */ - retval = NULL; - else - { - fname = q; - if (c == '\\') /* if we cut the name at a */ - fname++; /* '\', don't add it again */ - } - *q = c; - } - } - if (getcwd(buf, len) == NULL) - { - retval = NULL; - *buf = NUL; - } - /* - * Concatenate the file name to the path. - */ - if (strlen(buf) + strlen(fname) >= len - 1) - { - printf("ERROR: File name too long!\n"); - myexit(1); - } - add_pathsep(buf); - strcat(buf, fname); - if (p) - mch_chdir(olddir); - } - - /* Replace forward slashes with backslashes, required for the path to a - * command. */ - while ((p = strchr(buf, '/')) != NULL) - *p = '\\'; - - return retval; -# endif } #endif diff --git a/src/eval.c b/src/eval.c index 8670e12403..d4fba7fe0d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -187,7 +187,8 @@ static struct vimvar {VV_NAME("t_none", VAR_NUMBER), VV_RO}, {VV_NAME("t_job", VAR_NUMBER), VV_RO}, {VV_NAME("t_channel", VAR_NUMBER), VV_RO}, - {VV_NAME("termrgbresp", VAR_STRING), VV_RO}, + {VV_NAME("termrfgresp", VAR_STRING), VV_RO}, + {VV_NAME("termrbgresp", VAR_STRING), VV_RO}, {VV_NAME("termu7resp", VAR_STRING), VV_RO}, {VV_NAME("termstyleresp", VAR_STRING), VV_RO}, {VV_NAME("termblinkresp", VAR_STRING), VV_RO}, diff --git a/src/ex_cmds.c b/src/ex_cmds.c index b4351b23dc..60f47bbd24 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3400,7 +3400,7 @@ do_wqall(exarg_T *eap) FOR_ALL_BUFFERS(buf) { - if (bufIsChanged(buf)) + if (bufIsChanged(buf) && !bt_dontwrite(buf)) { /* * Check if there is a reason the buffer cannot be written: diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 95212738fd..b47cbe83e0 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -5102,29 +5102,6 @@ expand_filename( { if (n == 2) { -#ifdef UNIX - /* - * Only for Unix we check for more than one file name. - * For other systems spaces are considered to be part - * of the file name. - * Only check here if there is no wildcard, otherwise - * ExpandOne() will check for errors. This allows - * ":e `ls ve*.c`" on Unix. - */ - if (!has_wildcards) - for (p = eap->arg; *p; ++p) - { - /* skip escaped characters */ - if (p[1] && (*p == '\\' || *p == Ctrl_V)) - ++p; - else if (VIM_ISWHITE(*p)) - { - *errormsgp = (char_u *)_("E172: Only one file name allowed"); - return FAIL; - } - } -#endif - /* * Halve the number of backslashes (this is Vi compatible). * For Unix and OS/2, when wildcards are expanded, this is @@ -7301,6 +7278,7 @@ ex_quit(exarg_T *eap) */ if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) getout(0); + not_exiting(); #ifdef FEAT_GUI need_mouse_correct = TRUE; #endif @@ -7839,6 +7817,7 @@ ex_exit(exarg_T *eap) { if (only_one_window()) /* quit last window, exit Vim */ getout(0); + not_exiting(); # ifdef FEAT_GUI need_mouse_correct = TRUE; # endif diff --git a/src/if_mzsch.c b/src/if_mzsch.c index c9c5969483..54474bd807 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -757,7 +757,7 @@ mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose) mzscheme_enabled(int verbose) { return mzscheme_runtime_link_init( - DYNAMIC_MZSCH_DLL, DYNAMIC_MZGC_DLL, verbose) == OK; + (char *)p_mzschemedll, (char *)p_mzschemegcdll, verbose) == OK; } static void diff --git a/src/mbyte.c b/src/mbyte.c index fbc33da46a..9a08fb5881 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -1402,6 +1402,8 @@ static struct interval ambiguous[] = int utf_uint2cells(UINT32_T c) { + if (c >= 0x100 && utf_iscomposing((int)c)) + return 0; return utf_char2cells((int)c); } #endif diff --git a/src/msvc2015.bat b/src/msvc2015.bat new file mode 100644 index 0000000000..5621fca752 --- /dev/null +++ b/src/msvc2015.bat @@ -0,0 +1,33 @@ +@echo off +rem To be used on MS-Windows for Visual C++ 2015 (either Express or Community) +rem See INSTALLpc.txt for information. +rem +rem Usage: +rem For x86 builds run this without options: +rem msvc2015 +rem For x64 builds run this with "x86_amd64" option: +rem msvc2015 x86_amd64 +@echo on + +call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %* + +rem Use Windows SDK 7.1A for targeting Windows XP. +if "%ProgramFiles(x86)%"=="" ( + set "WinSdk71=%ProgramFiles%\Microsoft SDKs\Windows\v7.1A" +) else ( + set "WinSdk71=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A" +) +if not exist "%WinSdk71%" ( + echo Windows SDK 7.1A is not found. Targeting Windows Vista and later. + goto :eof +) + +set INCLUDE=%WinSdk71%\Include;%INCLUDE% +if "%Platform%"=="x64" ( + set "LIB=%WinSdk71%\Lib\x64;%LIB%" + set SUBSYSTEM_VER=5.02 +) else ( + set "LIB=%WinSdk71%\Lib;%LIB%" + set SUBSYSTEM_VER=5.01 +) +set CL=/D_USING_V110_SDK71_ diff --git a/src/normal.c b/src/normal.c index 8c2c6fcd32..aea7440eab 100644 --- a/src/normal.c +++ b/src/normal.c @@ -5988,7 +5988,9 @@ nv_scroll(cmdarg_T *cap) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; } - cursor_correct(); /* correct for 'so' */ + /* Correct for 'so', except when an operator is pending. */ + if (cap->oap->op_type == OP_NOP) + cursor_correct(); beginline(BL_SOL | BL_FIX); } diff --git a/src/ops.c b/src/ops.c index 6fb6947ee2..e366903c71 100644 --- a/src/ops.c +++ b/src/ops.c @@ -3259,8 +3259,8 @@ op_yank(oparg_T *oap, int deleting, int mess) clip_own_selection(&clip_plus); clip_gen_set_selection(&clip_plus); - if (!clip_isautosel_star() && !did_star - && curr == &(y_regs[PLUS_REGISTER])) + if (!clip_isautosel_star() && !clip_isautosel_plus() + && !did_star && curr == &(y_regs[PLUS_REGISTER])) { copy_yank_reg(&(y_regs[STAR_REGISTER])); clip_own_selection(&clip_star); diff --git a/src/option.c b/src/option.c index 950c68615f..b7e3028459 100644 --- a/src/option.c +++ b/src/option.c @@ -2084,6 +2084,24 @@ static struct vimoption options[] = {"mousetime", "mouset", P_NUM|P_VI_DEF, (char_u *)&p_mouset, PV_NONE, {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT}, + {"mzschemedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, +#if defined(DYNAMIC_MZSCHEME) + (char_u *)&p_mzschemedll, PV_NONE, + {(char_u *)DYNAMIC_MZSCH_DLL, (char_u *)0L} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)"", (char_u *)0L} +#endif + SCRIPTID_INIT}, + {"mzschemegcdll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, +#if defined(DYNAMIC_MZSCHEME) + (char_u *)&p_mzschemegcdll, PV_NONE, + {(char_u *)DYNAMIC_MZGC_DLL, (char_u *)0L} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)"", (char_u *)0L} +#endif + SCRIPTID_INIT}, {"mzquantum", "mzq", P_NUM, #ifdef FEAT_MZSCHEME (char_u *)&p_mzq, PV_NONE, @@ -3224,6 +3242,7 @@ static struct vimoption options[] = p_term("t_ms", T_MS) p_term("t_nd", T_ND) p_term("t_op", T_OP) + p_term("t_RF", T_RFG) p_term("t_RB", T_RBG) p_term("t_RC", T_CRC) p_term("t_RI", T_CRI) diff --git a/src/option.h b/src/option.h index 1c79a747ac..b494ee0cc6 100644 --- a/src/option.h +++ b/src/option.h @@ -681,6 +681,10 @@ EXTERN long p_mouset; /* 'mousetime' */ EXTERN int p_more; /* 'more' */ #ifdef FEAT_MZSCHEME EXTERN long p_mzq; /* 'mzquantum */ +# if defined(DYNAMIC_MZSCHEME) +EXTERN char_u *p_mzschemedll; /* 'mzschemedll' */ +EXTERN char_u *p_mzschemegcdll; /* 'mzschemegcdll' */ +# endif #endif #if defined(MSWIN) EXTERN int p_odev; /* 'opendevice' */ diff --git a/src/os_unix.c b/src/os_unix.c index 0748a33bc9..d2ac9df956 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4080,7 +4080,7 @@ wait4pid(pid_t child, waitstatus *status) mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc) { int i; - char_u *p; + char_u *p, *d; int inquote; /* @@ -4098,26 +4098,34 @@ mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc) if (i == 1) (*argv)[*argc] = (char *)p; ++*argc; + d = p; while (*p != NUL && (inquote || (*p != ' ' && *p != TAB))) { if (p[0] == '"') + /* quotes surrounding an argument and are dropped */ inquote = !inquote; - else if (p[0] == '\\' && p[1] != NUL) + else { - /* First pass: skip over "\ " and "\"". - * Second pass: Remove the backslash. */ - if (i == 1) - mch_memmove(p, p + 1, STRLEN(p)); - else + if (p[0] == '\\' && p[1] != NUL) + { + /* First pass: skip over "\ " and "\"". + * Second pass: Remove the backslash. */ ++p; + } + if (i == 1) + *d++ = *p; } ++p; } if (*p == NUL) + { + if (i == 1) + *d++ = NUL; break; + } if (i == 1) - *p++ = NUL; - p = skipwhite(p); + *d++ = NUL; + p = skipwhite(p + 1); } if (*argv == NULL) { diff --git a/src/proto/term.pro b/src/proto/term.pro index 65e67402aa..ef74f5647c 100644 --- a/src/proto/term.pro +++ b/src/proto/term.pro @@ -64,6 +64,8 @@ char_u *get_termcode(int i); void del_termcode(char_u *name); void set_mouse_topline(win_T *wp); int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen); +void term_get_fg_color(char_u *r, char_u *g, char_u *b); +void term_get_bg_color(char_u *r, char_u *g, char_u *b); char_u *replace_termcodes(char_u *from, char_u **bufp, int from_part, int do_lt, int special); int find_term_bykeys(char_u *src); void show_termcodes(void); diff --git a/src/tee/Make_mvc.mak b/src/tee/Make_mvc.mak index 7fe22df372..950100d3c8 100644 --- a/src/tee/Make_mvc.mak +++ b/src/tee/Make_mvc.mak @@ -1,10 +1,15 @@ # A very (if not the most) simplistic Makefile for MSVC +SUBSYSTEM = console +!if "$(SUBSYSTEM_VER)" != "" +SUBSYSTEM = $(SUBSYSTEM),$(SUBSYSTEM_VER) +!endif + CC=cl CFLAGS=/O2 /nologo tee.exe: tee.obj - $(CC) $(CFLAGS) /Fo$@ $** + $(CC) $(CFLAGS) /Fo$@ $** /link /subsystem:$(SUBSYSTEM) tee.obj: tee.c $(CC) $(CFLAGS) /c $** diff --git a/src/term.c b/src/term.c index 9fdb4f39e4..6cf91fe8ba 100644 --- a/src/term.c +++ b/src/term.c @@ -125,6 +125,17 @@ static int crv_status = STATUS_GET; /* Request Cursor position report: */ static int u7_status = STATUS_GET; +# ifdef FEAT_TERMINAL +/* Request foreground color report: */ +static int rfg_status = STATUS_GET; +static int fg_r = 0; +static int fg_g = 0; +static int fg_b = 0; +static int bg_r = 255; +static int bg_g = 255; +static int bg_b = 255; +# endif + /* Request background color report: */ static int rbg_status = STATUS_GET; @@ -882,6 +893,7 @@ static struct builtin_term builtin_termcaps[] = {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, # endif {(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")}, + {(int)KS_RFG, IF_EB("\033]10;?\007", ESC_STR "]10;?\007")}, {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")}, {(int)KS_U7, IF_EB("\033[6n", ESC_STR "[6n")}, # ifdef FEAT_TERMGUICOLORS @@ -1185,6 +1197,7 @@ static struct builtin_term builtin_termcaps[] = # endif {(int)KS_CRV, "[CRV]"}, {(int)KS_U7, "[U7]"}, + {(int)KS_RFG, "[RFG]"}, {(int)KS_RBG, "[RBG]"}, {K_UP, "[KU]"}, {K_DOWN, "[KD]"}, @@ -1614,7 +1627,7 @@ set_termname(char_u *term) {KS_TS, "ts"}, {KS_FS, "fs"}, {KS_CWP, "WP"}, {KS_CWS, "WS"}, {KS_CSI, "SI"}, {KS_CEI, "EI"}, - {KS_U7, "u7"}, {KS_RBG, "RB"}, + {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, {KS_8F, "8f"}, {KS_8B, "8b"}, {KS_CBE, "BE"}, {KS_CBD, "BD"}, {KS_CPS, "PS"}, {KS_CPE, "PE"}, @@ -3326,6 +3339,9 @@ settmode(int tmode) * them. */ if (tmode != TMODE_RAW && (crv_status == STATUS_SENT || u7_status == STATUS_SENT +#ifdef FEAT_TERMINAL + || rfg_status == STATUS_SENT +#endif || rbg_status == STATUS_SENT || rbm_status == STATUS_SENT || rcs_status == STATUS_SENT)) @@ -3397,6 +3413,9 @@ stoptermcap(void) /* May need to discard T_CRV, T_U7 or T_RBG response. */ if (crv_status == STATUS_SENT || u7_status == STATUS_SENT +# ifdef FEAT_TERMINAL + || rfg_status == STATUS_SENT +# endif || rbg_status == STATUS_SENT || rbm_status == STATUS_SENT || rcs_status == STATUS_SENT) @@ -3514,16 +3533,30 @@ may_req_bg_color(void) { if (can_get_termresponse() && starting == 0) { - /* Only request background if t_RB is set and 'background' wasn't - * changed. */ - if (rbg_status == STATUS_GET - && *T_RBG != NUL - && !option_was_set((char_u *)"bg")) + int didit = FALSE; + +# ifdef FEAT_TERMINAL + /* Only request foreground if t_RF is set. */ + if (rfg_status == STATUS_GET && *T_RFG != NUL) + { + LOG_TR("Sending FG request"); + out_str(T_RFG); + rfg_status = STATUS_SENT; + didit = TRUE; + } +# endif + + /* Only request background if t_RB is set. */ + if (rbg_status == STATUS_GET && *T_RBG != NUL) { LOG_TR("Sending BG request"); out_str(T_RBG); rbg_status = STATUS_SENT; + didit = TRUE; + } + if (didit) + { /* check for the characters now, otherwise they might be eaten by * get_keystroke() */ out_flush(); @@ -4694,46 +4727,72 @@ check_termcode( } } - /* Check for background color response from the terminal: + /* Check for fore/background color response from the terminal: * - * {lead}11;rgb:{rrrr}/{gggg}/{bbbb}{tail} + * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} * + * {code} is 10 for foreground, 11 for background * {lead} can be ] or OSC * {tail} can be '\007', \ or STERM. * * Consume any code that starts with "{lead}11;", it's also * possible that "rgba" is following. */ - else if (*T_RBG != NUL + else if ((*T_RBG != NUL || *T_RFG != NUL) && ((tp[0] == ESC && len >= 2 && tp[1] == ']') || tp[0] == OSC)) { j = 1 + (tp[0] == ESC); if (len >= j + 3 && (argp[0] != '1' - || argp[1] != '1' || argp[2] != ';')) + || (argp[1] != '1' && argp[1] != '0') + || argp[2] != ';')) i = 0; /* no match */ else for (i = j; i < len; ++i) if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) { + int is_bg = argp[1] == '1'; + if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 - && tp[j + 11] == '/' && tp[j + 16] == '/' - && !option_was_set((char_u *)"bg")) + && tp[j + 11] == '/' && tp[j + 16] == '/') { - char *newval = (3 * '6' < tp[j+7] + tp[j+12] + int rval = hexhex2nr(tp + j + 7); + int gval = hexhex2nr(tp + j + 12); + int bval = hexhex2nr(tp + j + 17); + + if (is_bg) + { + char *newval = (3 * '6' < tp[j+7] + tp[j+12] + tp[j+17]) ? "light" : "dark"; - LOG_TR("Received RBG response"); - rbg_status = STATUS_GOT; - if (STRCMP(p_bg, newval) != 0) - { - /* value differs, apply it */ - set_option_value((char_u *)"bg", 0L, + LOG_TR("Received RBG response"); + rbg_status = STATUS_GOT; +#ifdef FEAT_TERMINAL + bg_r = rval; + bg_g = gval; + bg_b = bval; +#endif + if (!option_was_set((char_u *)"bg") + && STRCMP(p_bg, newval) != 0) + { + /* value differs, apply it */ + set_option_value((char_u *)"bg", 0L, (char_u *)newval, 0); - reset_option_was_set((char_u *)"bg"); - redraw_asap(CLEAR); + reset_option_was_set((char_u *)"bg"); + redraw_asap(CLEAR); + } } +#ifdef FEAT_TERMINAL + else + { + LOG_TR("Received RFG response"); + rfg_status = STATUS_GOT; + fg_r = rval; + fg_g = gval; + fg_b = bval; + } +#endif } /* got finished code: consume it */ @@ -4741,7 +4800,8 @@ check_termcode( key_name[1] = (int)KE_IGNORE; slen = i + 1 + (tp[i] == ESC); # ifdef FEAT_EVAL - set_vim_var_string(VV_TERMRGBRESP, tp, slen); + set_vim_var_string(is_bg ? VV_TERMRBGRESP + : VV_TERMRFGRESP, tp, slen); # endif break; } @@ -5774,6 +5834,36 @@ check_termcode( return 0; /* no match found */ } +#if (defined(FEAT_TERMINAL) && defined(FEAT_TERMRESPONSE)) || defined(PROTO) +/* + * Get the text foreground color, if known. + */ + void +term_get_fg_color(char_u *r, char_u *g, char_u *b) +{ + if (rfg_status == STATUS_GOT) + { + *r = fg_r; + *g = fg_g; + *b = fg_b; + } +} + +/* + * Get the text background color, if known. + */ + void +term_get_bg_color(char_u *r, char_u *g, char_u *b) +{ + if (rbg_status == STATUS_GOT) + { + *r = bg_r; + *g = bg_g; + *b = bg_b; + } +} +#endif + /* * Replace any terminal code strings in from[] with the equivalent internal * vim representation. This is used for the "from" and "to" part of a diff --git a/src/term.h b/src/term.h index cc02aaaf32..8808f7db18 100644 --- a/src/term.h +++ b/src/term.h @@ -88,6 +88,7 @@ enum SpecialKey KS_CGP, /* get window position */ KS_CWS, /* set window size in characters */ KS_CRV, /* request version string */ + KS_RFG, /* request foreground color */ KS_RBG, /* request background color */ KS_CSI, /* start insert mode (bar cursor) */ KS_CEI, /* end insert mode (block cursor) */ @@ -185,6 +186,7 @@ extern char_u *(term_strings[]); /* current terminal strings */ #define T_CEI (TERM_STR(KS_CEI)) /* end insert mode */ #define T_CSR (TERM_STR(KS_CSR)) /* start replace mode */ #define T_CRV (TERM_STR(KS_CRV)) /* request version string */ +#define T_RFG (TERM_STR(KS_RFG)) /* request foreground RGB */ #define T_RBG (TERM_STR(KS_RBG)) /* request background RGB */ #define T_OP (TERM_STR(KS_OP)) /* original color pair */ #define T_U7 (TERM_STR(KS_U7)) /* request cursor position */ diff --git a/src/terminal.c b/src/terminal.c index 94fa4d48fc..7b8a0aad66 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -40,9 +40,9 @@ * TODO: * - in GUI vertical split causes problems. Cursor is flickering. (Hirohito * Higashi, 2017 Sep 19) + * - double click in Window toolbar starts Visual mode (but not always?). * - Shift-Tab does not work. * - after resizing windows overlap. (Boris Staletic, #2164) - * - double click in Window toolbar starts Visual mode. * - Redirecting output does not work on MS-Windows, Test_terminal_redir_file() * is disabled. * - cursor blinks in terminal on widows with a timer. (xtal8, #2142) @@ -56,7 +56,7 @@ * - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save * changes to "!shell". * (justrajdeep, 2017 Aug 22) - * - Redrawing is slow with Athena and Motif. + * - Redrawing is slow with Athena and Motif. Also other GUI? (Ramel Eshed) * - For the GUI fill termios with default values, perhaps like pangoterm: * http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134 * - if the job in the terminal does not support the mouse, we can use the @@ -2244,7 +2244,7 @@ term_update_window(win_T *wp) screen = vterm_obtain_screen(vterm); state = vterm_obtain_state(vterm); - if (wp->w_redr_type >= NOT_VALID) + if (wp->w_redr_type >= SOME_VALID) { term->tl_dirty_row_start = 0; term->tl_dirty_row_end = MAX_ROW; @@ -2301,7 +2301,6 @@ term_update_window(win_T *wp) if (vterm_screen_get_cell(screen, pos, &cell) == 0) vim_memset(&cell, 0, sizeof(cell)); - /* TODO: composing chars */ c = cell.chars[0]; if (c == NUL) { @@ -2313,7 +2312,18 @@ term_update_window(win_T *wp) { if (enc_utf8) { - if (c >= 0x80) + int i; + + /* composing chars */ + for (i = 0; i < Screen_mco + && i + 1 < VTERM_MAX_CHARS_PER_CELL; ++i) + { + ScreenLinesC[i][off] = cell.chars[i + 1]; + if (cell.chars[i + 1] == 0) + break; + } + if (c >= 0x80 || (Screen_mco > 0 + && ScreenLinesC[0][off] != 0)) { ScreenLines[off] = ' '; ScreenLinesUC[off] = c; @@ -2610,28 +2620,41 @@ create_vterm(term_T *term, int rows, int cols) if (cterm_bg >= 0) cterm_color2rgb(cterm_bg, bg); } -#if defined(WIN3264) && !defined(FEAT_GUI_W32) else { +#if defined(WIN3264) && !defined(FEAT_GUI_W32) int tmp; +#endif /* In an MS-Windows console we know the normal colors. */ if (cterm_normal_fg_color > 0) { cterm_color2rgb(cterm_normal_fg_color - 1, fg); +# if defined(WIN3264) && !defined(FEAT_GUI_W32) tmp = fg->red; fg->red = fg->blue; fg->blue = tmp; +# endif } +# ifdef FEAT_TERMRESPONSE + else + term_get_fg_color(&fg->red, &fg->green, &fg->blue); +# endif + if (cterm_normal_bg_color > 0) { cterm_color2rgb(cterm_normal_bg_color - 1, bg); +# if defined(WIN3264) && !defined(FEAT_GUI_W32) tmp = bg->red; bg->red = bg->blue; bg->blue = tmp; +# endif } +# ifdef FEAT_TERMRESPONSE + else + term_get_bg_color(&bg->red, &bg->green, &bg->blue); +# endif } -#endif vterm_state_set_default_colors(vterm_obtain_state(vterm), fg, bg); @@ -3146,7 +3169,7 @@ f_term_sendkeys(typval_T *argvars, typval_T *rettv) while (*msg != NUL) { send_keys_to_term(term, PTR2CHAR(msg), FALSE); - msg += MB_PTR2LEN(msg); + msg += MB_CPTR2LEN(msg); } } diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index e27ee93466..eb13761d22 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -14,9 +14,6 @@ SCRIPTS_FIRST = \ # Tests that run on all systems. SCRIPTS_ALL = \ test3.out \ - test4.out \ - test5.out \ - test7.out \ test8.out \ test14.out \ test15.out \ @@ -24,7 +21,6 @@ SCRIPTS_ALL = \ test20.out \ test28.out \ test29.out \ - test31.out \ test34.out \ test36.out \ test37.out \ @@ -36,7 +32,6 @@ SCRIPTS_ALL = \ test45.out \ test48.out \ test55.out \ - test60.out \ test64.out \ test66.out \ test68.out \ @@ -89,7 +84,6 @@ SCRIPTS_MORE4 = \ test32.out \ test59.out \ test72.out \ - test78.out \ test83.out @@ -125,6 +119,7 @@ NEW_TESTS = test_arabic.res \ test_digraph.res \ test_display.res \ test_edit.res \ + test_exists.res \ test_farsi.res \ test_file_size.res \ test_fnameescape.res \ @@ -196,6 +191,7 @@ NEW_TESTS = test_arabic.res \ test_vimscript.res \ test_visual.res \ test_winbar.res \ + test_winbuf_close.res \ test_window_id.res \ test_windows_home.res \ test_writefile.res \ @@ -207,6 +203,4 @@ NEW_TESTS = test_arabic.res \ # Explicit dependencies. test49.out: test49.vim -test60.out: test60.vim - test_options.res test_alot.res: opt_test.vim diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak index 2c00a156f1..05978ade2f 100644 --- a/src/testdir/Make_dos.mak +++ b/src/testdir/Make_dos.mak @@ -118,17 +118,17 @@ bench_re_freeze.out: bench_re_freeze.vim newtests: $(NEW_TESTS) .vim.res: - @echo "$(VIMPROG)" > vimcmd + @echo $(VIMPROG) > vimcmd $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim @del vimcmd test_gui.res: test_gui.vim - @echo "$(VIMPROG)" > vimcmd + @echo $(VIMPROG) > vimcmd $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim @del vimcmd test_gui_init.res: test_gui_init.vim - @echo "$(VIMPROG)" > vimcmd + @echo $(VIMPROG) > vimcmd $(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim @del vimcmd diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak index 3d7cf3fc65..ecfa97e4c7 100644 --- a/src/testdir/Make_ming.mak +++ b/src/testdir/Make_ming.mak @@ -68,7 +68,7 @@ win32: fixff nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) newtests fixff: -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=dos|upd" +q *.in *.ok -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=unix|upd" +q \ - dotest.in test60.ok test_listchars.ok \ + dotest.in test_listchars.ok \ test_wordcount.ok clean: @@ -120,17 +120,17 @@ bench_re_freeze.out: bench_re_freeze.vim newtests: $(NEW_TESTS) .vim.res: - @echo "$(VIMPROG)" > vimcmd + @echo $(VIMPROG) > vimcmd $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim @$(DEL) vimcmd test_gui.res: test_gui.vim - @echo "$(VIMPROG)" > vimcmd + @echo $(VIMPROG) > vimcmd $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $< @$(DEL) vimcmd test_gui_init.res: test_gui_init.vim - @echo "$(VIMPROG)" > vimcmd + @echo $(VIMPROG) > vimcmd $(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< @$(DEL) vimcmd diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms index 5d7770d330..efed68f9ca 100644 --- a/src/testdir/Make_vms.mms +++ b/src/testdir/Make_vms.mms @@ -73,20 +73,20 @@ VIMPROG = <->vim.exe .SUFFIXES : .out .in -SCRIPT = test1.out test3.out test4.out test5.out \ - test7.out test8.out \ +SCRIPT = test1.out test3.out \ + test8.out \ test14.out test15.out \ test19.out test20.out \ - test28.out test29.out test30.out test31.out test32.out \ + test28.out test29.out test30.out test32.out \ test34.out test36.out test37.out \ test38.out test39.out test40.out test42.out \ test44.out test45.out \ test48.out test49.out test54.out \ - test55.out test60.out \ + test55.out \ test64.out \ test66.out test68.out test69.out \ test72.out \ - test77a.out test78.out test79.out \ + test77a.out test79.out \ test88.out \ test94.out \ test95.out test99.out \ diff --git a/src/testdir/Makefile b/src/testdir/Makefile index ce1c24cd68..3a69c6c1ac 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -126,18 +126,21 @@ newtests: newtestssilent newtestssilent: $(NEW_TESTS) -.vim.res: - @echo "$(RUN_VIMTEST)" > vimcmd +.vim.res: writevimcmd + @echo "$(VIMPROG)" > vimcmd + @echo "$(RUN_VIMTEST)" >> vimcmd $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim @rm vimcmd test_gui.res: test_gui.vim - @echo "$(RUN_GVIMTEST)" > vimcmd + @echo "$(VIMPROG)" > vimcmd + @echo "$(RUN_GVIMTEST)" >> vimcmd $(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $< @rm vimcmd test_gui_init.res: test_gui_init.vim - @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" > vimcmd + @echo "$(VIMPROG)" > vimcmd + @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" >> vimcmd $(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< @rm vimcmd diff --git a/src/testdir/xterm_ramp.vim b/src/testdir/color_ramp.vim similarity index 100% rename from src/testdir/xterm_ramp.vim rename to src/testdir/color_ramp.vim diff --git a/src/testdir/main.aap b/src/testdir/main.aap index eb80a81f0d..54f7eb2565 100644 --- a/src/testdir/main.aap +++ b/src/testdir/main.aap @@ -4,12 +4,12 @@ VimProg ?= ../vim -Scripts = test1.out test2.out test3.out test4.out test5.out test6.out - test7.out test8.out test11.out +Scripts = test1.out test2.out test3.out test6.out + test8.out test11.out test12.out test13.out test14.out test15.out test17.out test18.out test19.out test20.out test21.out test25.out test27.out - test28.out test29.out test30.out test31.out test32.out + test28.out test29.out test30.out test32.out test34.out test36.out test37.out test38.out test39.out test40.out test42.out test44.out test45.out test46.out test47.out diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index d07710afce..245b51c64f 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -250,6 +250,9 @@ endif " Execute the tests in alphabetical order. for s:test in sort(s:tests) + " Silence, please! + set belloff=all + call RunTheTest(s:test) if len(v:errors) > 0 && index(s:flaky, s:test) >= 0 diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim index 6bbdb07a95..2d9b1c9568 100644 --- a/src/testdir/shared.vim +++ b/src/testdir/shared.vim @@ -170,6 +170,15 @@ func s:feedkeys(timer) call feedkeys('x', 'nt') endfunc +" Get $VIMPROG to run Vim executable. +" The Makefile writes it as the first line in the "vimcmd" file. +func GetVimProg() + if !filereadable('vimcmd') + return '' + endif + return readfile('vimcmd')[0] +endfunc + " Get the command to run Vim, with -u NONE and --not-a-term arguments. " If there is an argument use it instead of "NONE". " Returns an empty string on error. @@ -182,7 +191,12 @@ func GetVimCommand(...) else let name = a:1 endif - let cmd = readfile('vimcmd')[0] + " For Unix Makefile writes the command to use in the second line of the + " "vimcmd" file, including environment options. + " Other Makefiles just write the executable in the first line, so fall back + " to that if there is no second line. + let lines = readfile('vimcmd') + let cmd = get(lines, 1, lines[0]) let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '') if cmd !~ '-u '. name let cmd = cmd . ' -u ' . name diff --git a/src/testdir/test31.in b/src/testdir/test31.in deleted file mode 100644 index ff5a4992ba..0000000000 --- a/src/testdir/test31.in +++ /dev/null @@ -1,95 +0,0 @@ -Test for commands that close windows and/or buffers: -:quit -:close -:hide -:only -:sall -:all -:ball -:buf -:edit - -STARTTEST -:so small.vim -GA 1:$w! Xtest1 -$r2:$w! Xtest2 -$r3:$w! Xtest3 -:n! Xtest1 Xtest2 -A 1:set hidden -:" test for working :n when hidden set; write "testtext 2" -:n -:w! test.out -:" test for failing :rew when hidden not set; write "testtext 2 2" -:set nohidden -A 2:rew -:w >>test.out -:" test for working :rew when hidden set; write "testtext 1 1" -:set hidden -:rew -:w >>test.out -:" test for :all keeping a buffer when it's modified; write "testtext 1 1 1" -:set nohidden -A 1:sp -:n Xtest2 Xtest3 -:all -:1wincmd w -:w >>test.out -:" test abandoning changed buffer, should be unloaded even when 'hidden' set -:" write "testtext 2 2" twice -:set hidden -A 1:q! -:w >>test.out -:unhide -:w >>test.out -:" test ":hide" hides anyway when 'hidden' not set; write "testtext 3" -:set nohidden -A 2:hide -:w >>test.out -:" test ":edit" failing in modified buffer when 'hidden' not set -:" write "testtext 3 3" -A 3:e Xtest1 -:w >>test.out -:" test ":edit" working in modified buffer when 'hidden' set; write "testtext 1" -:set hidden -:e Xtest1 -:w >>test.out -:" test ":close" not hiding when 'hidden' not set in modified buffer; -:" write "testtext 3 3 3" -:sp Xtest3 -:set nohidden -A 3:close -:w >>test.out -:" test ":close!" does hide when 'hidden' not set in modified buffer; -:" write "testtext 1" -A 3:close! -:w >>test.out -:set nohidden -:" test ":all!" hides changed buffer; write "testtext 2 2 2" -:sp Xtest4 -GA 4:all! -:1wincmd w -:w >>test.out -:" -:" test ":q!" and hidden buffer. -:bw! Xtest1 Xtest2 Xtest3 Xtest4 -:sp Xtest1 -:wincmd w -:bw! -:set modified -:bot sp Xtest2 -:set modified -:bot sp Xtest3 -:set modified -:wincmd t -:hide -:q! -:w >>test.out -:q! -:w >>test.out -:q! -:call append(line('$'), "Oh, Not finished yet.") -:w >>test.out -:qa! -ENDTEST - -testtext diff --git a/src/testdir/test31.ok b/src/testdir/test31.ok deleted file mode 100644 index 39531974c6..0000000000 --- a/src/testdir/test31.ok +++ /dev/null @@ -1,14 +0,0 @@ -testtext 2 -testtext 2 2 -testtext 1 1 -testtext 1 1 1 -testtext 2 2 -testtext 2 2 -testtext 3 -testtext 3 3 -testtext 1 -testtext 3 3 3 -testtext 1 -testtext 2 2 2 -testtext 3 -testtext 1 diff --git a/src/testdir/test4.in b/src/testdir/test4.in deleted file mode 100644 index b3ee49baa4..0000000000 --- a/src/testdir/test4.in +++ /dev/null @@ -1,34 +0,0 @@ -Test for autocommand that changes current buffer on BufEnter event. -Check if modelines are interpreted for the correct buffer. - -STARTTEST -:so small.vim -:set nocompatible viminfo+=nviminfo -:au BufEnter Xxx brew -/start of -:.,/end of/w! Xxx " write test file Xxx -:set ai modeline modelines=3 -:sp Xxx " split to Xxx, autocmd will do :brew -G?this is a -othis should be auto-indented -: " Append text with autoindent to this file -:au! BufEnter Xxx -:buf Xxx " go to Xxx, no autocmd anymore -G?this is a -othis should be in column 1:wq " append text without autoindent to Xxx -G:r Xxx " include Xxx in the current file -:set fo+=r " issue #57 do not move cursor on when autoindent is set -Go# abcdef2hi -d0o# abcdef2hid0: -:?startstart?,$w! test.out -:qa! -ENDTEST - -startstart -start of test file Xxx -vim: set noai : - this is a test - this is a test - this is a test - this is a test -end of test file Xxx diff --git a/src/testdir/test4.ok b/src/testdir/test4.ok deleted file mode 100644 index d032e4c319..0000000000 --- a/src/testdir/test4.ok +++ /dev/null @@ -1,20 +0,0 @@ -startstart -start of test file Xxx -vim: set noai : - this is a test - this is a test - this is a test - this is a test - this should be auto-indented -end of test file Xxx -start of test file Xxx -vim: set noai : - this is a test - this is a test - this is a test - this is a test -this should be in column 1 -end of test file Xxx -# abc -def -def diff --git a/src/testdir/test5.in b/src/testdir/test5.in deleted file mode 100644 index e19e20d59b..0000000000 --- a/src/testdir/test5.in +++ /dev/null @@ -1,29 +0,0 @@ -Test for autocommand that deletes the current buffer on BufLeave event. -Also test deleting the last buffer, should give a new, empty buffer. - -STARTTEST -:so small.vim -:au BufLeave Xxx bwipe -/start of -:.,/end of/w! Xxx " write test file Xxx -:sp Xxx " split to Xxx -:bwipe " delete buffer Xxx, now we're back here -G?this is a -othis is some more text -: " Append some text to this file -:?start?,$w! test.out " Write current file contents -:bwipe test.out " delete alternate buffer -:au bufleave test5.in bwipe -:bwipe! " delete current buffer, get an empty one -ithis is another test line:w >>test.out -: " append an extra line to the output file -:qa! -ENDTEST - -start of test file Xxx -vim: set noai : - this is a test - this is a test - this is a test - this is a test -end of test file Xxx diff --git a/src/testdir/test5.ok b/src/testdir/test5.ok deleted file mode 100644 index 6743060794..0000000000 --- a/src/testdir/test5.ok +++ /dev/null @@ -1,9 +0,0 @@ -start of test file Xxx -vim: set noai : - this is a test - this is a test - this is a test - this is a test -this is some more text -end of test file Xxx -this is another test line diff --git a/src/testdir/test60.in b/src/testdir/test60.in deleted file mode 100644 index d3b299beba..0000000000 --- a/src/testdir/test60.in +++ /dev/null @@ -1,601 +0,0 @@ -Tests for the exists() and has() functions. vim: set ft=vim ts=8 sw=2 : - -STARTTEST -:so small.vim -:function! RunTest(str, result) - if exists(a:str) == a:result - echo "OK" - else - echo "FAILED: Checking for " . a:str - endif -endfunction -:function! TestExists() - augroup myagroup - autocmd! BufEnter *.my echo "myfile edited" - autocmd! FuncUndefined UndefFun exec "fu UndefFun()\nendfu" - augroup END - set rtp+=./sautest - - let test_cases = [] - - " valid autocmd group - let test_cases += [['#myagroup', 1]] - " valid autocmd group with garbage - let test_cases += [['#myagroup+b', 0]] - " Valid autocmd group and event - let test_cases += [['#myagroup#BufEnter', 1]] - " Valid autocmd group, event and pattern - let test_cases += [['#myagroup#BufEnter#*.my', 1]] - " Valid autocmd event - let test_cases += [['#BufEnter', 1]] - " Valid autocmd event and pattern - let test_cases += [['#BufEnter#*.my', 1]] - " Non-existing autocmd group or event - let test_cases += [['#xyzagroup', 0]] - " Non-existing autocmd group and valid autocmd event - let test_cases += [['#xyzagroup#BufEnter', 0]] - " Valid autocmd group and event with no matching pattern - let test_cases += [['#myagroup#CmdwinEnter', 0]] - " Valid autocmd group and non-existing autocmd event - let test_cases += [['#myagroup#xyzacmd', 0]] - " Valid autocmd group and event and non-matching pattern - let test_cases += [['#myagroup#BufEnter#xyzpat', 0]] - " Valid autocmd event and non-matching pattern - let test_cases += [['#BufEnter#xyzpat', 0]] - " Empty autocmd group, event and pattern - let test_cases += [['###', 0]] - " Empty autocmd group and event or empty event and pattern - let test_cases += [['##', 0]] - " Valid autocmd event - let test_cases += [['##FileReadCmd', 1]] - " Non-existing autocmd event - let test_cases += [['##MySpecialCmd', 0]] - - " Existing and working option (long form) - let test_cases += [['&textwidth', 1]] - " Existing and working option (short form) - let test_cases += [['&tw', 1]] - " Existing and working option with garbage - let test_cases += [['&tw-', 0]] - " Global option - let test_cases += [['&g:errorformat', 1]] - " Local option - let test_cases += [['&l:errorformat', 1]] - " Negative form of existing and working option (long form) - let test_cases += [['&nojoinspaces', 0]] - " Negative form of existing and working option (short form) - let test_cases += [['&nojs', 0]] - " Non-existing option - let test_cases += [['&myxyzoption', 0]] - - " Existing and working option (long form) - let test_cases += [['+incsearch', 1]] - " Existing and working option with garbage - let test_cases += [['+incsearch!1', 0]] - " Existing and working option (short form) - let test_cases += [['+is', 1]] - " Existing option that is hidden. - let test_cases += [['+autoprint', 0]] - - " Existing environment variable - let $EDITOR_NAME = 'Vim Editor' - let test_cases += [['$EDITOR_NAME', 1]] - " Non-existing environment variable - let test_cases += [['$NON_ENV_VAR', 0]] - - " Valid internal function - let test_cases += [['*bufnr', 1]] - " Valid internal function with () - let test_cases += [['*bufnr()', 1]] - " Non-existing internal function - let test_cases += [['*myxyzfunc', 0]] - " Valid internal function with garbage - let test_cases += [['*bufnr&6', 0]] - - " Valid user defined function - let test_cases += [['*TestExists', 1]] - " Non-existing user defined function - let test_cases += [['*MyxyzFunc', 0]] - - " Function that may be created by FuncUndefined event - let test_cases += [['*UndefFun', 0]] - " Function that may be created by script autoloading - let test_cases += [['*footest#F', 0]] - - redir! > test.out - - for [test_case, result] in test_cases - echo test_case . ": " . result - call RunTest(test_case, result) - endfor - - " Valid internal command (full match) - echo ':edit: 2' - if exists(':edit') == 2 - echo "OK" - else - echo "FAILED" - endif - - " Valid internal command (full match) with garbage - echo ':edit/a: 0' - if exists(':edit/a') == 0 - echo "OK" - else - echo "FAILED" - endif - - " Valid internal command (partial match) - echo ':q: 1' - if exists(':q') == 1 - echo "OK" - else - echo "FAILED" - endif - - " Non-existing internal command - echo ':invalidcmd: 0' - if !exists(':invalidcmd') - echo "OK" - else - echo "FAILED" - endif - - " User defined command (full match) - command! MyCmd :echo 'My command' - echo ':MyCmd: 2' - if exists(':MyCmd') == 2 - echo "OK" - else - echo "FAILED" - endif - - " User defined command (partial match) - command! MyOtherCmd :echo 'Another command' - echo ':My: 3' - if exists(':My') == 3 - echo "OK" - else - echo "FAILED" - endif - - " Command modifier - echo ':rightbelow: 2' - if exists(':rightbelow') == 2 - echo "OK" - else - echo "FAILED" - endif - - " Non-existing user defined command (full match) - delcommand MyCmd - - echo ':MyCmd: 0' - if !exists(':MyCmd') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing user defined command (partial match) - delcommand MyOtherCmd - - echo ':My: 0' - if !exists(':My') - echo "OK" - else - echo "FAILED" - endif - - " Valid local variable - let local_var = 1 - echo 'local_var: 1' - if exists('local_var') - echo "OK" - else - echo "FAILED" - endif - - " Valid local variable with garbage - let local_var = 1 - echo 'local_var%n: 0' - if !exists('local_var%n') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing local variable - unlet local_var - echo 'local_var: 0' - if !exists('local_var') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing autoload variable that may be autoloaded - echo 'footest#x: 0' - if !exists('footest#x') - echo "OK" - else - echo "FAILED" - endif - - " Valid local list - let local_list = ["blue", "orange"] - echo 'local_list: 1' - if exists('local_list') - echo "OK" - else - echo "FAILED" - endif - - " Valid local list item - echo 'local_list[1]: 1' - if exists('local_list[1]') - echo "OK" - else - echo "FAILED" - endif - - " Valid local list item with garbage - echo 'local_list[1]+5: 0' - if !exists('local_list[1]+5') - echo "OK" - else - echo "FAILED" - endif - - " Invalid local list item - echo 'local_list[2]: 0' - if !exists('local_list[2]') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing local list - unlet local_list - echo 'local_list: 0' - if !exists('local_list') - echo "OK" - else - echo "FAILED" - endif - - " Valid local dictionary - let local_dict = {"xcord":100, "ycord":2} - echo 'local_dict: 1' - if exists('local_dict') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing local dictionary - unlet local_dict - echo 'local_dict: 0' - if !exists('local_dict') - echo "OK" - else - echo "FAILED" - endif - - " Existing local curly-brace variable - let str = "local" - let curly_{str}_var = 1 - echo 'curly_' . str . '_var: 1' - if exists('curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing local curly-brace variable - unlet curly_{str}_var - echo 'curly_' . str . '_var: 0' - if !exists('curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - - " Existing global variable - let g:global_var = 1 - echo 'g:global_var: 1' - if exists('g:global_var') - echo "OK" - else - echo "FAILED" - endif - - " Existing global variable with garbage - echo 'g:global_var-n: 1' - if !exists('g:global_var-n') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing global variable - unlet g:global_var - echo 'g:global_var: 0' - if !exists('g:global_var') - echo "OK" - else - echo "FAILED" - endif - - " Existing global list - let g:global_list = ["blue", "orange"] - echo 'g:global_list: 1' - if exists('g:global_list') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing global list - unlet g:global_list - echo 'g:global_list: 0' - if !exists('g:global_list') - echo "OK" - else - echo "FAILED" - endif - - " Existing global dictionary - let g:global_dict = {"xcord":100, "ycord":2} - echo 'g:global_dict: 1' - if exists('g:global_dict') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing global dictionary - unlet g:global_dict - echo 'g:global_dict: 0' - if !exists('g:global_dict') - echo "OK" - else - echo "FAILED" - endif - - " Existing global curly-brace variable - let str = "global" - let g:curly_{str}_var = 1 - echo 'g:curly_' . str . '_var: 1' - if exists('g:curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing global curly-brace variable - unlet g:curly_{str}_var - echo 'g:curly_' . str . '_var: 0' - if !exists('g:curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - " Existing window variable - echo 'w:window_var: 1' - let w:window_var = 1 - if exists('w:window_var') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing window variable - unlet w:window_var - echo 'w:window_var: 0' - if !exists('w:window_var') - echo "OK" - else - echo "FAILED" - endif - - " Existing window list - let w:window_list = ["blue", "orange"] - echo 'w:window_list: 1' - if exists('w:window_list') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing window list - unlet w:window_list - echo 'w:window_list: 0' - if !exists('w:window_list') - echo "OK" - else - echo "FAILED" - endif - - " Existing window dictionary - let w:window_dict = {"xcord":100, "ycord":2} - echo 'w:window_dict: 1' - if exists('w:window_dict') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing window dictionary - unlet w:window_dict - echo 'w:window_dict: 0' - if !exists('w:window_dict') - echo "OK" - else - echo "FAILED" - endif - - " Existing window curly-brace variable - let str = "window" - let w:curly_{str}_var = 1 - echo 'w:curly_' . str . '_var: 1' - if exists('w:curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing window curly-brace variable - unlet w:curly_{str}_var - echo 'w:curly_' . str . '_var: 0' - if !exists('w:curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - " Existing buffer variable - echo 'b:buffer_var: 1' - let b:buffer_var = 1 - if exists('b:buffer_var') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing buffer variable - unlet b:buffer_var - echo 'b:buffer_var: 0' - if !exists('b:buffer_var') - echo "OK" - else - echo "FAILED" - endif - - " Existing buffer list - let b:buffer_list = ["blue", "orange"] - echo 'b:buffer_list: 1' - if exists('b:buffer_list') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing buffer list - unlet b:buffer_list - echo 'b:buffer_list: 0' - if !exists('b:buffer_list') - echo "OK" - else - echo "FAILED" - endif - - " Existing buffer dictionary - let b:buffer_dict = {"xcord":100, "ycord":2} - echo 'b:buffer_dict: 1' - if exists('b:buffer_dict') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing buffer dictionary - unlet b:buffer_dict - echo 'b:buffer_dict: 0' - if !exists('b:buffer_dict') - echo "OK" - else - echo "FAILED" - endif - - " Existing buffer curly-brace variable - let str = "buffer" - let b:curly_{str}_var = 1 - echo 'b:curly_' . str . '_var: 1' - if exists('b:curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing buffer curly-brace variable - unlet b:curly_{str}_var - echo 'b:curly_' . str . '_var: 0' - if !exists('b:curly_{str}_var') - echo "OK" - else - echo "FAILED" - endif - - " Script-local tests - source test60.vim - - " Existing Vim internal variable - echo 'v:version: 1' - if exists('v:version') - echo "OK" - else - echo "FAILED" - endif - - " Non-existing Vim internal variable - echo 'v:non_exists_var: 0' - if !exists('v:non_exists_var') - echo "OK" - else - echo "FAILED" - endif - - " Function arguments - function TestFuncArg(func_arg, ...) - echo 'a:func_arg: 1' - if exists('a:func_arg') - echo "OK" - else - echo "FAILED" - endif - - echo 'a:non_exists_arg: 0' - if !exists('a:non_exists_arg') - echo "OK" - else - echo "FAILED" - endif - - echo 'a:1: 1' - if exists('a:1') - echo "OK" - else - echo "FAILED" - endif - - echo 'a:2: 0' - if !exists('a:2') - echo "OK" - else - echo "FAILED" - endif - endfunction - - call TestFuncArg("arg1", "arg2") - - echo ' g:footest#x =' g:footest#x - echo ' footest#F()' footest#F() - echo 'UndefFun()' UndefFun() - - redir END -endfunction -:call TestExists() -:" -:delfunc TestExists -:delfunc RunTest -:delfunc TestFuncArg -:edit! test.out -:set ff=unix -:w -:qa! -:while getchar(1) | call getchar() | endwhile -ENDTEST - diff --git a/src/testdir/test60.ok b/src/testdir/test60.ok deleted file mode 100644 index 0c382ad281..0000000000 --- a/src/testdir/test60.ok +++ /dev/null @@ -1,206 +0,0 @@ - -#myagroup: 1 -OK -#myagroup+b: 0 -OK -#myagroup#BufEnter: 1 -OK -#myagroup#BufEnter#*.my: 1 -OK -#BufEnter: 1 -OK -#BufEnter#*.my: 1 -OK -#xyzagroup: 0 -OK -#xyzagroup#BufEnter: 0 -OK -#myagroup#CmdwinEnter: 0 -OK -#myagroup#xyzacmd: 0 -OK -#myagroup#BufEnter#xyzpat: 0 -OK -#BufEnter#xyzpat: 0 -OK -###: 0 -OK -##: 0 -OK -##FileReadCmd: 1 -OK -##MySpecialCmd: 0 -OK -&textwidth: 1 -OK -&tw: 1 -OK -&tw-: 0 -OK -&g:errorformat: 1 -OK -&l:errorformat: 1 -OK -&nojoinspaces: 0 -OK -&nojs: 0 -OK -&myxyzoption: 0 -OK -+incsearch: 1 -OK -+incsearch!1: 0 -OK -+is: 1 -OK -+autoprint: 0 -OK -$EDITOR_NAME: 1 -OK -$NON_ENV_VAR: 0 -OK -*bufnr: 1 -OK -*bufnr(): 1 -OK -*myxyzfunc: 0 -OK -*bufnr&6: 0 -OK -*TestExists: 1 -OK -*MyxyzFunc: 0 -OK -*UndefFun: 0 -OK -*footest#F: 0 -OK -:edit: 2 -OK -:edit/a: 0 -OK -:q: 1 -OK -:invalidcmd: 0 -OK -:MyCmd: 2 -OK -:My: 3 -OK -:rightbelow: 2 -OK -:MyCmd: 0 -OK -:My: 0 -OK -local_var: 1 -OK -local_var%n: 0 -OK -local_var: 0 -OK -footest#x: 0 -OK -local_list: 1 -OK -local_list[1]: 1 -OK -local_list[1]+5: 0 -OK -local_list[2]: 0 -OK -local_list: 0 -OK -local_dict: 1 -OK -local_dict: 0 -OK -curly_local_var: 1 -OK -curly_local_var: 0 -OK -g:global_var: 1 -OK -g:global_var-n: 1 -OK -g:global_var: 0 -OK -g:global_list: 1 -OK -g:global_list: 0 -OK -g:global_dict: 1 -OK -g:global_dict: 0 -OK -g:curly_global_var: 1 -OK -g:curly_global_var: 0 -OK -w:window_var: 1 -OK -w:window_var: 0 -OK -w:window_list: 1 -OK -w:window_list: 0 -OK -w:window_dict: 1 -OK -w:window_dict: 0 -OK -w:curly_window_var: 1 -OK -w:curly_window_var: 0 -OK -b:buffer_var: 1 -OK -b:buffer_var: 0 -OK -b:buffer_list: 1 -OK -b:buffer_list: 0 -OK -b:buffer_dict: 1 -OK -b:buffer_dict: 0 -OK -b:curly_buffer_var: 1 -OK -b:curly_buffer_var: 0 -OK -s:script_var: 1 -OK -s:script_var: 0 -OK -s:script_list: 1 -OK -s:script_list: 0 -OK -s:script_dict: 1 -OK -s:script_dict: 0 -OK -s:curly_script_var: 1 -OK -s:curly_script_var: 0 -OK -*s:my_script_func: 1 -OK -*s:my_script_func: 0 -OK -v:version: 1 -OK -v:non_exists_var: 0 -OK -a:func_arg: 1 -OK -a:non_exists_arg: 0 -OK -a:1: 1 -OK -a:2: 0 -OK - g:footest#x = 1 - footest#F() 0 -UndefFun() 0 diff --git a/src/testdir/test60.vim b/src/testdir/test60.vim deleted file mode 100644 index f1157f73f9..0000000000 --- a/src/testdir/test60.vim +++ /dev/null @@ -1,98 +0,0 @@ -" Vim script for exists() function test -" Script-local variables are checked here - -" Existing script-local variable -let s:script_var = 1 -echo 's:script_var: 1' -if exists('s:script_var') - echo "OK" -else - echo "FAILED" -endif - -" Non-existing script-local variable -unlet s:script_var -echo 's:script_var: 0' -if !exists('s:script_var') - echo "OK" -else - echo "FAILED" -endif - -" Existing script-local list -let s:script_list = ["blue", "orange"] -echo 's:script_list: 1' -if exists('s:script_list') - echo "OK" -else - echo "FAILED" -endif - -" Non-existing script-local list -unlet s:script_list -echo 's:script_list: 0' -if !exists('s:script_list') - echo "OK" -else - echo "FAILED" -endif - -" Existing script-local dictionary -let s:script_dict = {"xcord":100, "ycord":2} -echo 's:script_dict: 1' -if exists('s:script_dict') - echo "OK" -else - echo "FAILED" -endif - -" Non-existing script-local dictionary -unlet s:script_dict -echo 's:script_dict: 0' -if !exists('s:script_dict') - echo "OK" -else - echo "FAILED" -endif - -" Existing script curly-brace variable -let str = "script" -let s:curly_{str}_var = 1 -echo 's:curly_' . str . '_var: 1' -if exists('s:curly_{str}_var') - echo "OK" -else - echo "FAILED" -endif - -" Non-existing script-local curly-brace variable -unlet s:curly_{str}_var -echo 's:curly_' . str . '_var: 0' -if !exists('s:curly_{str}_var') - echo "OK" -else - echo "FAILED" -endif - -" Existing script-local function -function! s:my_script_func() -endfunction - -echo '*s:my_script_func: 1' -if exists('*s:my_script_func') - echo "OK" -else - echo "FAILED" -endif - -" Non-existing script-local function -delfunction s:my_script_func - -echo '*s:my_script_func: 0' -if !exists('*s:my_script_func') - echo "OK" -else - echo "FAILED" -endif -unlet str - diff --git a/src/testdir/test7.in b/src/testdir/test7.in deleted file mode 100644 index b9cc0585f6..0000000000 --- a/src/testdir/test7.in +++ /dev/null @@ -1,26 +0,0 @@ -Test for autocommand that changes the buffer list, when doing ":ball". - -STARTTEST -:so small.vim -/^start of -A1:.,/end of/w! Xxx1 " write test file Xxx1 -:sp Xxx1 -:close -$r2:.,/end of/w! Xxx2 " write test file Xxx2 -:sp Xxx2 -:close -$r3:.,/end of/w! Xxx3 " write test file Xxx3 -:sp Xxx3 -:close -:au BufReadPost Xxx2 bwipe -$r4:ball " open window for all args, close Xxx2 -:.,$w! test.out " Write contents of this file -:w >>test.out " Append contents of second window (Xxx1) -:/^start of/,$w >>test.out " Append contents of last window (this file) -:qa! -ENDTEST - -start of test file Xxx - this is a test - this is a test -end of test file Xxx diff --git a/src/testdir/test7.ok b/src/testdir/test7.ok deleted file mode 100644 index a0d1ff94a3..0000000000 --- a/src/testdir/test7.ok +++ /dev/null @@ -1,12 +0,0 @@ -start of test file Xxx4 - this is a test - this is a test -end of test file Xxx -start of test file Xxx1 - this is a test - this is a test -end of test file Xxx -start of test file Xxx4 - this is a test - this is a test -end of test file Xxx diff --git a/src/testdir/test78.in b/src/testdir/test78.in deleted file mode 100644 index e97f4a4695..0000000000 --- a/src/testdir/test78.in +++ /dev/null @@ -1,46 +0,0 @@ -Inserts 10000 lines with text to fill the swap file with two levels of pointer -blocks. Then recovers from the swap file and checks all text is restored. - -We need about 10000 lines of 100 characters to get two levels of pointer -blocks. - -STARTTEST -:so small.vim -:set nocp fileformat=unix undolevels=-1 viminfo+=nviminfo belloff=all -:e! Xtest -ggdG -:let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789" -:let i = 1 -:let linecount = 10000 -:while i <= linecount | call append(i - 1, i . text) | let i += 1 | endwhile -:preserve -:" get the name of the swap file -:redir => swapname -:swapname -:redir END -:let swapname = substitute(swapname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', '') -:" make a copy of the swap file in Xswap -:set bin -:exe 'sp ' . swapname -:w! Xswap -:echo swapname -:set nobin -:new -:only! -:bwipe! Xtest -:call rename('Xswap', swapname) -:recover Xtest -:call delete(swapname) -:new -:call append(0, 'recovery start') -:wincmd w -:let linedollar = line('$') -:if linedollar < linecount | exe 'wincmd w' | call append(line('$'), "expected " . linecount . " lines but found only " . linedollar) | exe 'wincmd w' | let linecount = linedollar | endif -:let i = 1 -:while i <= linecount | if getline(i) != i . text | exe 'wincmd w' | call append(line('$'), i . ' differs') | exe 'wincmd w' | endif | let i += 1 | endwhile -:q! -:call append(line('$'), 'recovery end') -:w! test.out -:qa! -ENDTEST - diff --git a/src/testdir/test78.ok b/src/testdir/test78.ok deleted file mode 100644 index 6c3ecefe3c..0000000000 --- a/src/testdir/test78.ok +++ /dev/null @@ -1,3 +0,0 @@ -recovery start - -recovery end diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 189cd82d12..ad133033ac 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -1,7 +1,6 @@ " A series of tests that can run in one Vim invocation. " This makes testing go faster, since Vim doesn't need to restart. -set belloff=all source test_assign.vim source test_bufline.vim source test_cd.vim diff --git a/src/testdir/test_alot_utf8.vim b/src/testdir/test_alot_utf8.vim index 8c9cfd2a9b..13e227b6ea 100644 --- a/src/testdir/test_alot_utf8.vim +++ b/src/testdir/test_alot_utf8.vim @@ -5,7 +5,6 @@ " runtest.vim. Checking for the multi_byte feature is in the individual " files, so that they can be run by themselves. -set belloff=all source test_charsearch_utf8.vim source test_expr_utf8.vim source test_matchadd_conceal_utf8.vim diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 8cfcf0da9e..2384fefc7e 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -1,6 +1,5 @@ " Tests for autocommands -set belloff=all func! s:cleanup_buffers() abort for bnr in range(1, bufnr('$')) @@ -352,7 +351,9 @@ endfunc " Closing a window might cause an endless loop " E814 for older Vims func Test_autocmd_bufwipe_in_SessLoadPost() + edit Xtest tabnew + file Xsomething set noswapfile mksession! @@ -360,7 +361,7 @@ func Test_autocmd_bufwipe_in_SessLoadPost() \ 'let v:swapchoice="e"', \ 'augroup test_autocmd_sessionload', \ 'autocmd!', - \ 'autocmd SessionLoadPost * 4bw!', + \ 'autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"', \ 'augroup END', \ '', \ 'func WriteErrors()', @@ -436,6 +437,8 @@ func Test_OptionSet() return endif + badd test_autocmd.vim + call test_override('starting', 1) set nocp au OptionSet * :call s:AutoCommandOptionSet(expand("")) @@ -529,9 +532,10 @@ func Test_OptionSet() let g:options=[['backup', 0, 1, 'local']] " try twice, first time, shouldn't trigger because option name is invalid, " second time, it should trigger - call assert_fails("call setbufvar(1, '&l:bk', 1)", "E355") + let bnum = bufnr('%') + call assert_fails("call setbufvar(bnum, '&l:bk', 1)", "E355") " should trigger, use correct option name - call setbufvar(1, '&backup', 1) + call setbufvar(bnum, '&backup', 1) call assert_equal([], g:options) call assert_equal(g:opt[0], g:opt[1]) @@ -645,3 +649,133 @@ func Test_BufleaveWithDelete() new bwipe! Xfile1 endfunc + +" Test for autocommand that changes the buffer list, when doing ":ball". +func Test_Acmd_BufAll() + enew! + %bwipe! + call writefile(['Test file Xxx1'], 'Xxx1') + call writefile(['Test file Xxx2'], 'Xxx2') + call writefile(['Test file Xxx3'], 'Xxx3') + + " Add three files to the buffer list + split Xxx1 + close + split Xxx2 + close + split Xxx3 + close + + " Wipe the buffer when the buffer is opened + au BufReadPost Xxx2 bwipe + + call append(0, 'Test file Xxx4') + ball + + call assert_equal(2, winnr('$')) + call assert_equal('Xxx1', bufname(winbufnr(winnr('$')))) + wincmd t + + au! BufReadPost + %bwipe! + call delete('Xxx1') + call delete('Xxx2') + call delete('Xxx3') + enew! | only +endfunc + +" Test for autocommand that changes current buffer on BufEnter event. +" Check if modelines are interpreted for the correct buffer. +func Test_Acmd_BufEnter() + %bwipe! + call writefile(['start of test file Xxx1', + \ "\this is a test", + \ 'end of test file Xxx1'], 'Xxx1') + call writefile(['start of test file Xxx2', + \ 'vim: set noai :', + \ "\this is a test", + \ 'end of test file Xxx2'], 'Xxx2') + + au BufEnter Xxx2 brew + set ai modeline modelines=3 + edit Xxx1 + " edit Xxx2, autocmd will do :brew + edit Xxx2 + exe "normal G?this is a\" + " Append text with autoindent to this file + normal othis should be auto-indented + call assert_equal("\this should be auto-indented", getline('.')) + call assert_equal(3, line('.')) + " Remove autocmd and edit Xxx2 again + au! BufEnter Xxx2 + buf! Xxx2 + exe "normal G?this is a\" + " append text without autoindent to Xxx + normal othis should be in column 1 + call assert_equal("this should be in column 1", getline('.')) + call assert_equal(4, line('.')) + + %bwipe! + call delete('Xxx1') + call delete('Xxx2') + set ai&vim modeline&vim modelines&vim +endfunc + +" Test for issue #57 +" do not move cursor on when autoindent is set +func Test_ai_CTRL_O() + enew! + set ai + let save_fo = &fo + set fo+=r + exe "normal o# abcdef\2hi\\d0\" + exe "normal o# abcdef\2hi\d0\" + call assert_equal(['# abc', 'def', 'def'], getline(2, 4)) + + set ai&vim + let &fo = save_fo + enew! +endfunc + +" Test for autocommand that deletes the current buffer on BufLeave event. +" Also test deleting the last buffer, should give a new, empty buffer. +func Test_BufLeave_Wipe() + %bwipe! + let content = ['start of test file Xxx', + \ 'this is a test', + \ 'end of test file Xxx'] + call writefile(content, 'Xxx1') + call writefile(content, 'Xxx2') + + au BufLeave Xxx2 bwipe + edit Xxx1 + split Xxx2 + " delete buffer Xxx2, we should be back to Xxx1 + bwipe + call assert_equal('Xxx1', bufname('%')) + call assert_equal(1, winnr('$')) + + " Create an alternate buffer + %write! test.out + call assert_equal('test.out', bufname('#')) + " delete alternate buffer + bwipe test.out + call assert_equal('Xxx1', bufname('%')) + call assert_equal('', bufname('#')) + + au BufLeave Xxx1 bwipe + " delete current buffer, get an empty one + bwipe! + call assert_equal(1, line('$')) + call assert_equal('', bufname('%')) + let g:bufinfo = getbufinfo() + call assert_equal(1, len(g:bufinfo)) + + call delete('Xxx1') + call delete('Xxx2') + %bwipe + au! BufLeave + + " check that bufinfo doesn't contain a pointer to freed memory + call test_garbagecollect_now() +endfunc diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 6b070934ba..0a71cef010 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1590,6 +1590,22 @@ func Test_collapse_buffers() bwipe! endfunc +func Test_cmd_parsing() + if !has('unix') + return + endif + call assert_false(filereadable("file with space")) + let job = job_start('touch "file with space"') + call WaitFor('filereadable("file with space")') + call assert_true(filereadable("file with space")) + call delete("file with space") + + let job = job_start('touch file\ with\ space') + call WaitFor('filereadable("file with space")') + call assert_true(filereadable("file with space")) + call delete("file with space") +endfunc + func Test_raw_passes_nul() if !executable('cat') || !has('job') return diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index f9499acf09..ff190821cd 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -1,6 +1,5 @@ " Tests for editing the command line. -set belloff=all func Test_complete_tab() call writefile(['testfile'], 'Xtestfile') diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim index c1dcfb8057..3273dcbd5f 100644 --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -1,5 +1,4 @@ " Tests for diff mode -set belloff=all func Test_diff_fold_sync() enew! diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim index 30dc9a4683..6290680305 100644 --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -3,7 +3,6 @@ if !has("digraphs") || !has("multi_byte") finish endif -set belloff=all func! Put_Dig(chars) exe "norm! o\".a:chars diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index 2e4d5e30e7..435159db54 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -3,7 +3,6 @@ if exists("+t_kD") let &t_kD="[3;*~" endif -set belloff= " Needed for testing basic rightleft: Test_edit_rightleft source view_util.vim @@ -26,7 +25,6 @@ func! Test_edit_01() " set for Travis CI? " set nocp noesckeys new - set belloff=backspace " 1) empty buffer call assert_equal([''], getline(1,'$')) " 2) delete in an empty line @@ -59,7 +57,6 @@ func! Test_edit_01() call cursor(1, 1) call feedkeys("A\\", 'tnix') call assert_equal(["abc def", "ghi jkl"], getline(1, 2)) - set belloff= let &bs=_bs bw! endfunc @@ -475,13 +472,11 @@ func! Test_edit_00a_CTRL_A() new call setline(1, repeat([''], 5)) call cursor(1, 1) - set belloff=all try call feedkeys("A\", 'tnix') catch /^Vim\%((\a\+)\)\=:E29/ call assert_true(1, 'E29 error caught') endtry - set belloff= call cursor(1, 1) call feedkeys("Afoobar \", 'tnix') call cursor(2, 1) @@ -510,7 +505,6 @@ endfunc func! Test_edit_CTRL_G() new - set belloff=all call setline(1, ['foobar', 'foobar', 'foobar']) call cursor(2, 4) call feedkeys("ioooooooo\k\.\", 'tnix') @@ -524,7 +518,6 @@ func! Test_edit_CTRL_G() call assert_equal([0, 3, 7, 0], getpos('.')) call feedkeys("i\j\", 'tnix') call assert_equal([0, 3, 6, 0], getpos('.')) - set belloff= bw! endfunc @@ -604,7 +597,6 @@ func! Test_edit_CTRL_K() %d call setline(1, 'A') call cursor(1, 1) - set belloff=all let v:testing = 1 try call feedkeys("A\\\", 'tnix') @@ -612,7 +604,6 @@ func! Test_edit_CTRL_K() " error sleeps 2 seconds, when v:testing is not set let v:testing = 0 endtry - set belloff= call delete('Xdictionary.txt') if has("multi_byte") @@ -853,7 +844,6 @@ func! Test_edit_CTRL_T() %d call setline(1, 'mad') call cursor(1, 1) - set belloff=all let v:testing = 1 try call feedkeys("A\\\", 'tnix') @@ -861,7 +851,6 @@ func! Test_edit_CTRL_T() " error sleeps 2 seconds, when v:testing is not set let v:testing = 0 endtry - set belloff= call assert_equal(['mad'], getline(1, '$')) call delete('Xthesaurus') bw! @@ -1033,7 +1022,6 @@ endfunc func! Test_edit_LEFT_RIGHT() " Left, Shift-Left, Right, Shift-Right new - set belloff=all call setline(1, ['abc def ghi', 'ABC DEF GHI', 'ZZZ YYY XXX']) let _ww=&ww set ww= @@ -1075,7 +1063,6 @@ func! Test_edit_LEFT_RIGHT() call feedkeys("A\\", 'tnix') call assert_equal([0, 3, 1, 0], getpos('.')) let &ww = _ww - set belloff= bw! endfunc @@ -1135,7 +1122,6 @@ func! Test_edit_MOUSE() endfunc func! Test_edit_PAGEUP_PAGEDOWN() - set belloff=all 10new call setline(1, repeat(['abc def ghi'], 30)) call cursor(1, 1) @@ -1231,12 +1217,10 @@ func! Test_edit_PAGEUP_PAGEDOWN() call assert_equal([0, 30, 11, 0], getpos('.')) call feedkeys("A\\", 'tnix') call assert_equal([0, 30, 11, 0], getpos('.')) - set startofline belloff= bw! endfunc func! Test_edit_forbidden() - set belloff=error,esc new " 1) edit in the sandbox is not allowed call setline(1, 'a') @@ -1293,7 +1277,6 @@ func! Test_edit_forbidden() set norevins nofkmap endtry endif - set belloff= bw! endfunc diff --git a/src/testdir/test_exists.vim b/src/testdir/test_exists.vim new file mode 100644 index 0000000000..fd34be83b0 --- /dev/null +++ b/src/testdir/test_exists.vim @@ -0,0 +1,321 @@ +" Tests for the exists() function +func Test_exists() + augroup myagroup + autocmd! BufEnter *.my echo "myfile edited" + autocmd! FuncUndefined UndefFun exec "fu UndefFun()\nendfu" + augroup END + set rtp+=./sautest + + " valid autocmd group + call assert_equal(1, exists('#myagroup')) + " valid autocmd group with garbage + call assert_equal(0, exists('#myagroup+b')) + " Valid autocmd group and event + call assert_equal(1, exists('#myagroup#BufEnter')) + " Valid autocmd group, event and pattern + call assert_equal(1, exists('#myagroup#BufEnter#*.my')) + " Valid autocmd event + call assert_equal(1, exists('#BufEnter')) + " Valid autocmd event and pattern + call assert_equal(1, exists('#BufEnter#*.my')) + " Non-existing autocmd group or event + call assert_equal(0, exists('#xyzagroup')) + " Non-existing autocmd group and valid autocmd event + call assert_equal(0, exists('#xyzagroup#BufEnter')) + " Valid autocmd group and event with no matching pattern + call assert_equal(0, exists('#myagroup#CmdwinEnter')) + " Valid autocmd group and non-existing autocmd event + call assert_equal(0, exists('#myagroup#xyzacmd')) + " Valid autocmd group and event and non-matching pattern + call assert_equal(0, exists('#myagroup#BufEnter#xyzpat')) + " Valid autocmd event and non-matching pattern + call assert_equal(0, exists('#BufEnter#xyzpat')) + " Empty autocmd group, event and pattern + call assert_equal(0, exists('###')) + " Empty autocmd group and event or empty event and pattern + call assert_equal(0, exists('##')) + " Valid autocmd event + call assert_equal(1, exists('##FileReadCmd')) + " Non-existing autocmd event + call assert_equal(0, exists('##MySpecialCmd')) + + " Existing and working option (long form) + call assert_equal(1, exists('&textwidth')) + " Existing and working option (short form) + call assert_equal(1, exists('&tw')) + " Existing and working option with garbage + call assert_equal(0, exists('&tw-')) + " Global option + call assert_equal(1, exists('&g:errorformat')) + " Local option + call assert_equal(1, exists('&l:errorformat')) + " Negative form of existing and working option (long form) + call assert_equal(0, exists('&nojoinspaces')) + " Negative form of existing and working option (short form) + call assert_equal(0, exists('&nojs')) + " Non-existing option + call assert_equal(0, exists('&myxyzoption')) + + " Existing and working option (long form) + call assert_equal(1, exists('+incsearch')) + " Existing and working option with garbage + call assert_equal(0, exists('+incsearch!1')) + " Existing and working option (short form) + call assert_equal(1, exists('+is')) + " Existing option that is hidden. + call assert_equal(0, exists('+autoprint')) + + " Existing environment variable + let $EDITOR_NAME = 'Vim Editor' + call assert_equal(1, exists('$EDITOR_NAME')) + " Non-existing environment variable + call assert_equal(0, exists('$NON_ENV_VAR')) + + " Valid internal function + call assert_equal(1, exists('*bufnr')) + " Valid internal function with () + call assert_equal(1, exists('*bufnr()')) + " Non-existing internal function + call assert_equal(0, exists('*myxyzfunc')) + " Valid internal function with garbage + call assert_equal(0, exists('*bufnr&6')) + " Valid user defined function + call assert_equal(1, exists('*Test_exists')) + " Non-existing user defined function + call assert_equal(0, exists('*MyxyzFunc')) + " Function that may be created by FuncUndefined event + call assert_equal(0, exists('*UndefFun')) + " Function that may be created by script autoloading + call assert_equal(0, exists('*footest#F')) + + " Valid internal command (full match) + call assert_equal(2, exists(':edit')) + " Valid internal command (full match) with garbage + call assert_equal(0, exists(':edit/a')) + " Valid internal command (partial match) + call assert_equal(1, exists(':q')) + " Non-existing internal command + call assert_equal(0, exists(':invalidcmd')) + + " User defined command (full match) + command! MyCmd :echo 'My command' + call assert_equal(2, exists(':MyCmd')) + " User defined command (partial match) + command! MyOtherCmd :echo 'Another command' + call assert_equal(3, exists(':My')) + + " Command modifier + call assert_equal(2, exists(':rightbelow')) + + " Non-existing user defined command (full match) + delcommand MyCmd + call assert_equal(0, exists(':MyCmd')) + + " Non-existing user defined command (partial match) + delcommand MyOtherCmd + call assert_equal(0, exists(':My')) + + " Valid local variable + let local_var = 1 + call assert_equal(1, exists('local_var')) + " Valid local variable with garbage + call assert_equal(0, exists('local_var%n')) + " Non-existing local variable + unlet local_var + call assert_equal(0, exists('local_var')) + + " Non-existing autoload variable that may be autoloaded + call assert_equal(0, exists('footest#x')) + + " Valid local list + let local_list = ["blue", "orange"] + call assert_equal(1, exists('local_list')) + " Valid local list item + call assert_equal(1, exists('local_list[1]')) + " Valid local list item with garbage + call assert_equal(0, exists('local_list[1]+5')) + " Invalid local list item + call assert_equal(0, exists('local_list[2]')) + " Non-existing local list + unlet local_list + call assert_equal(0, exists('local_list')) + " Valid local dictionary + let local_dict = {"xcord":100, "ycord":2} + call assert_equal(1, exists('local_dict')) + " Non-existing local dictionary + unlet local_dict + call assert_equal(0, exists('local_dict')) + " Existing local curly-brace variable + let str = "local" + let curly_{str}_var = 1 + call assert_equal(1, exists('curly_{str}_var')) + " Non-existing local curly-brace variable + unlet curly_{str}_var + call assert_equal(0, exists('curly_{str}_var')) + + " Existing global variable + let g:global_var = 1 + call assert_equal(1, exists('g:global_var')) + " Existing global variable with garbage + call assert_equal(0, exists('g:global_var-n')) + " Non-existing global variable + unlet g:global_var + call assert_equal(0, exists('g:global_var')) + " Existing global list + let g:global_list = ["blue", "orange"] + call assert_equal(1, exists('g:global_list')) + " Non-existing global list + unlet g:global_list + call assert_equal(0, exists('g:global_list')) + " Existing global dictionary + let g:global_dict = {"xcord":100, "ycord":2} + call assert_equal(1, exists('g:global_dict')) + " Non-existing global dictionary + unlet g:global_dict + call assert_equal(0, exists('g:global_dict')) + " Existing global curly-brace variable + let str = "global" + let g:curly_{str}_var = 1 + call assert_equal(1, exists('g:curly_{str}_var')) + " Non-existing global curly-brace variable + unlet g:curly_{str}_var + call assert_equal(0, exists('g:curly_{str}_var')) + + " Existing window variable + let w:window_var = 1 + call assert_equal(1, exists('w:window_var')) + " Non-existing window variable + unlet w:window_var + call assert_equal(0, exists('w:window_var')) + " Existing window list + let w:window_list = ["blue", "orange"] + call assert_equal(1, exists('w:window_list')) + " Non-existing window list + unlet w:window_list + call assert_equal(0, exists('w:window_list')) + " Existing window dictionary + let w:window_dict = {"xcord":100, "ycord":2} + call assert_equal(1, exists('w:window_dict')) + " Non-existing window dictionary + unlet w:window_dict + call assert_equal(0, exists('w:window_dict')) + " Existing window curly-brace variable + let str = "window" + let w:curly_{str}_var = 1 + call assert_equal(1, exists('w:curly_{str}_var')) + " Non-existing window curly-brace variable + unlet w:curly_{str}_var + call assert_equal(0, exists('w:curly_{str}_var')) + + " Existing tab variable + let t:tab_var = 1 + call assert_equal(1, exists('t:tab_var')) + " Non-existing tab variable + unlet t:tab_var + call assert_equal(0, exists('t:tab_var')) + " Existing tab list + let t:tab_list = ["blue", "orange"] + call assert_equal(1, exists('t:tab_list')) + " Non-existing tab list + unlet t:tab_list + call assert_equal(0, exists('t:tab_list')) + " Existing tab dictionary + let t:tab_dict = {"xcord":100, "ycord":2} + call assert_equal(1, exists('t:tab_dict')) + " Non-existing tab dictionary + unlet t:tab_dict + call assert_equal(0, exists('t:tab_dict')) + " Existing tab curly-brace variable + let str = "tab" + let t:curly_{str}_var = 1 + call assert_equal(1, exists('t:curly_{str}_var')) + " Non-existing tab curly-brace variable + unlet t:curly_{str}_var + call assert_equal(0, exists('t:curly_{str}_var')) + + " Existing buffer variable + let b:buffer_var = 1 + call assert_equal(1, exists('b:buffer_var')) + " Non-existing buffer variable + unlet b:buffer_var + call assert_equal(0, exists('b:buffer_var')) + " Existing buffer list + let b:buffer_list = ["blue", "orange"] + call assert_equal(1, exists('b:buffer_list')) + " Non-existing buffer list + unlet b:buffer_list + call assert_equal(0, exists('b:buffer_list')) + " Existing buffer dictionary + let b:buffer_dict = {"xcord":100, "ycord":2} + call assert_equal(1, exists('b:buffer_dict')) + " Non-existing buffer dictionary + unlet b:buffer_dict + call assert_equal(0, exists('b:buffer_dict')) + " Existing buffer curly-brace variable + let str = "buffer" + let b:curly_{str}_var = 1 + call assert_equal(1, exists('b:curly_{str}_var')) + " Non-existing buffer curly-brace variable + unlet b:curly_{str}_var + call assert_equal(0, exists('b:curly_{str}_var')) + + " Existing Vim internal variable + call assert_equal(1, exists('v:version')) + " Non-existing Vim internal variable + call assert_equal(0, exists('v:non_exists_var')) + + " Existing script-local variable + let s:script_var = 1 + call assert_equal(1, exists('s:script_var')) + " Non-existing script-local variable + unlet s:script_var + call assert_equal(0, exists('s:script_var')) + " Existing script-local list + let s:script_list = ["blue", "orange"] + call assert_equal(1, exists('s:script_list')) + " Non-existing script-local list + unlet s:script_list + call assert_equal(0, exists('s:script_list')) + " Existing script-local dictionary + let s:script_dict = {"xcord":100, "ycord":2} + call assert_equal(1, exists('s:script_dict')) + " Non-existing script-local dictionary + unlet s:script_dict + call assert_equal(0, exists('s:script_dict')) + " Existing script curly-brace variable + let str = "script" + let s:curly_{str}_var = 1 + call assert_equal(1, exists('s:curly_{str}_var')) + " Non-existing script-local curly-brace variable + unlet s:curly_{str}_var + call assert_equal(0, exists('s:curly_{str}_var')) + + " Existing script-local function + function! s:my_script_func() + endfunction + + echo '*s:my_script_func: 1' + call assert_equal(1, exists('*s:my_script_func')) + + " Non-existing script-local function + delfunction s:my_script_func + + call assert_equal(0, exists('*s:my_script_func')) + unlet str + + call assert_equal(1, g:footest#x) + call assert_equal(0, footest#F()) + call assert_equal(0, UndefFun()) +endfunc + +" exists() test for Function arguments +func FuncArg_Tests(func_arg, ...) + call assert_equal(1, exists('a:func_arg')) + call assert_equal(0, exists('a:non_exists_arg')) + call assert_equal(1, exists('a:1')) + call assert_equal(0, exists('a:2')) +endfunc + +func Test_exists_funcarg() + call FuncArg_Tests("arg1", "arg2") +endfunc diff --git a/src/testdir/test_file_size.vim b/src/testdir/test_file_size.vim index 8dac3b2ac4..3e78a7b23c 100644 --- a/src/testdir/test_file_size.vim +++ b/src/testdir/test_file_size.vim @@ -13,7 +13,7 @@ func Test_File_Size() endif new - set belloff=all fileformat=unix undolevels=-1 + set fileformat=unix undolevels=-1 for i in range(1, 2000000, 100) call append(i, range(i, i + 99)) endfor @@ -26,7 +26,7 @@ func Test_File_Size() enew! call delete('Xtest') - set belloff& fileformat& undolevels& + set fileformat& undolevels& endfunc " Test for writing and reading a file of over 100 Kbyte diff --git a/src/testdir/test_gn.vim b/src/testdir/test_gn.vim index f56e707da1..7a77d9d88b 100644 --- a/src/testdir/test_gn.vim +++ b/src/testdir/test_gn.vim @@ -1,7 +1,6 @@ " Test for gn command func Test_gn_command() - set belloff=all noautocmd new " replace a single char by itsself quoted: call setline('.', 'abc x def x ghi x jkl') @@ -121,7 +120,6 @@ func Test_gn_command() sil! %d_ set wrapscan&vim - set belloff&vim endfu " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_marks.vim b/src/testdir/test_marks.vim index 18a0c71aab..d22f9051b5 100644 --- a/src/testdir/test_marks.vim +++ b/src/testdir/test_marks.vim @@ -68,3 +68,55 @@ func Test_setpos() call win_gotoid(twowin) bwipe! endfunc + +func Test_marks_cmd() + new Xone + call setline(1, ['aaa', 'bbb']) + norm! maG$mB + w! + new Xtwo + call setline(1, ['ccc', 'ddd']) + norm! $mcGmD + w! + + b Xone + let a=split(execute('marks'), "\n") + call assert_equal(9, len(a)) + call assert_equal('mark line col file/text', a[0]) + call assert_equal(" ' 2 0 bbb", a[1]) + call assert_equal(' a 1 0 aaa', a[2]) + call assert_equal(' B 2 2 bbb', a[3]) + call assert_equal(' D 2 0 Xtwo', a[4]) + call assert_equal(' " 1 0 aaa', a[5]) + call assert_equal(' [ 1 0 aaa', a[6]) + call assert_equal(' ] 2 0 bbb', a[7]) + call assert_equal(' . 2 0 bbb', a[8]) + + b Xtwo + let a=split(execute('marks'), "\n") + call assert_equal(9, len(a)) + call assert_equal('mark line col file/text', a[0]) + call assert_equal(" ' 1 0 ccc", a[1]) + call assert_equal(' c 1 2 ccc', a[2]) + call assert_equal(' B 2 2 Xone', a[3]) + call assert_equal(' D 2 0 ddd', a[4]) + call assert_equal(' " 2 0 ddd', a[5]) + call assert_equal(' [ 1 0 ccc', a[6]) + call assert_equal(' ] 2 0 ddd', a[7]) + call assert_equal(' . 2 0 ddd', a[8]) + + b Xone + delmarks aB + let a=split(execute('marks aBcD'), "\n") + call assert_equal(2, len(a)) + call assert_equal('mark line col file/text', a[0]) + call assert_equal(' D 2 0 Xtwo', a[1]) + + b Xtwo + delmarks cD + call assert_fails('marks aBcD', 'E283:') + + call delete('Xone') + call delete('Xtwo') + %bwipe +endfunc diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index b64b4e4074..f6b1a43b81 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -1,6 +1,5 @@ " Test for various Normal mode commands -set belloff=all func! Setup_NewWindow() 10new call setline(1, range(1,100)) diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim index 7dcaa60622..66cbb47834 100644 --- a/src/testdir/test_packadd.vim +++ b/src/testdir/test_packadd.vim @@ -1,6 +1,5 @@ " Tests for 'packpath' and :packadd -set belloff=all func SetUp() let s:topdir = expand('%:h') . '/Xdir' diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim index fdd51de51c..b770e560dc 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -38,7 +38,6 @@ endfu func! Test_popup_complete() new inoremap =ListMonths() - set belloff=all " - select original typed text before the completion started call feedkeys("aJu\\\\", 'tx') @@ -215,7 +214,6 @@ func! Test_popup_complete() call feedkeys("aM\\\", 'tx') call assert_equal(["March", "M", "March"], getline(1,4)) %d - set belloff& endfu @@ -517,7 +515,6 @@ endfunc func Test_completion_respect_bs_option() new - set belloff=all let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"] set bs=indent,eol @@ -533,7 +530,6 @@ func Test_completion_respect_bs_option() call feedkeys("A\\\\\\\", "tx") call assert_equal('', getline(1)) - set belloff& bw! endfunc @@ -620,7 +616,6 @@ endfunc func Test_complete_CTRLN_startofbuffer() new - set belloff=all call setline(1, [ 'organize(cupboard, 3, 2);', \ 'prioritize(bureau, 8, 7);', \ 'realize(bannister, 4, 4);', @@ -631,7 +626,6 @@ func Test_complete_CTRLN_startofbuffer() \ 'railing.moralize(3,9);'] call feedkeys("qai\\.\3wdW\q3@a", 'tx') call assert_equal(expected, getline(1,'$')) - set belloff& bwipe! endfunc @@ -643,10 +637,10 @@ func Test_popup_and_window_resize() if h < 15 return endif - let g:buf = term_start([$VIMPROG, '--clean', '-c', 'set noswapfile'], {'term_rows': h / 3}) - call term_sendkeys(g:buf, (h / 3 - 1)."o\G") - call term_sendkeys(g:buf, "i\") + let g:buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': h / 3}) + call term_sendkeys(g:buf, (h / 3 - 1)."o\") call term_wait(g:buf, 200) + call term_sendkeys(g:buf, "Gi\") call term_sendkeys(g:buf, "\") call term_wait(g:buf, 100) " popup first entry "!" must be at the top diff --git a/src/testdir/test_recover.vim b/src/testdir/test_recover.vim index 2e34985fed..a9934a1624 100644 --- a/src/testdir/test_recover.vim +++ b/src/testdir/test_recover.vim @@ -15,4 +15,48 @@ func Test_recover_root_dir() set dir& endfunc -" TODO: move recover tests from test78.in to here. +" Inserts 10000 lines with text to fill the swap file with two levels of pointer +" blocks. Then recovers from the swap file and checks all text is restored. +" +" We need about 10000 lines of 100 characters to get two levels of pointer +" blocks. +func Test_swap_file() + set fileformat=unix undolevels=-1 + edit! Xtest + let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789" + let i = 1 + let linecount = 10000 + while i <= linecount + call append(i - 1, i . text) + let i += 1 + endwhile + $delete + preserve + " get the name of the swap file + let swname = split(execute("swapname"))[0] + let swname = substitute(swname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', '') + " make a copy of the swap file in Xswap + set binary + exe 'sp ' . swname + w! Xswap + set nobinary + new + only! + bwipe! Xtest + call rename('Xswap', swname) + recover Xtest + call delete(swname) + let linedollar = line('$') + call assert_equal(linecount, linedollar) + if linedollar < linecount + let linecount = linedollar + endif + let i = 1 + while i <= linecount + call assert_equal(i . text, getline(i)) + let i += 1 + endwhile + + set undolevels& + enew! | only +endfunc diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim index 5ae101f1ec..e6a46ff145 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -1,6 +1,5 @@ " Test for the search command -set belloff=all func Test_search_cmdline() if !exists('+incsearch') return diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 0cd14d1dda..d213673909 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -681,3 +681,69 @@ func Test_terminal_tmap() call TerminalTmap(1) call TerminalTmap(0) endfunc + +func Test_terminal_wall() + let buf = Run_shell_in_terminal({}) + wall + call Stop_shell_in_terminal(buf) + call term_wait(buf) + exe buf . 'bwipe' + unlet g:job +endfunc + +func Test_terminal_composing_unicode() + let save_enc = &encoding + set encoding=utf-8 + + if has('win32') + let cmd = "cmd /K chcp 65001" + let lnum = [3, 6, 9] + else + let cmd = &shell + let lnum = [1, 3, 5] + endif + + enew + let buf = term_start(cmd, {'curwin': bufnr('')}) + let job = term_getjob(buf) + call term_wait(buf, 50) + + " ascii + composing + let txt = "a\u0308bc" + call term_sendkeys(buf, "echo " . txt . "\r") + call term_wait(buf, 50) + call assert_match("echo " . txt, term_getline(buf, lnum[0])) + call assert_equal(txt, term_getline(buf, lnum[0] + 1)) + let l = term_scrape(buf, lnum[0] + 1) + call assert_equal("a\u0308", l[0].chars) + call assert_equal("b", l[1].chars) + call assert_equal("c", l[2].chars) + + " multibyte + composing + let txt = "\u304b\u3099\u304e\u304f\u3099\u3052\u3053\u3099" + call term_sendkeys(buf, "echo " . txt . "\r") + call term_wait(buf, 50) + call assert_match("echo " . txt, term_getline(buf, lnum[1])) + call assert_equal(txt, term_getline(buf, lnum[1] + 1)) + let l = term_scrape(buf, lnum[1] + 1) + call assert_equal("\u304b\u3099", l[0].chars) + call assert_equal("\u304e", l[1].chars) + call assert_equal("\u304f\u3099", l[2].chars) + call assert_equal("\u3052", l[3].chars) + call assert_equal("\u3053\u3099", l[4].chars) + + " \u00a0 + composing + let txt = "abc\u00a0\u0308" + call term_sendkeys(buf, "echo " . txt . "\r") + call term_wait(buf, 50) + call assert_match("echo " . txt, term_getline(buf, lnum[2])) + call assert_equal(txt, term_getline(buf, lnum[2] + 1)) + let l = term_scrape(buf, lnum[2] + 1) + call assert_equal("\u00a0\u0308", l[3].chars) + + call term_sendkeys(buf, "exit\r") + call WaitFor('job_status(job) == "dead"') + call assert_equal('dead', job_status(job)) + bwipe! + let &encoding = save_enc +endfunc diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim index 8b92ba15d9..684f197f5f 100644 --- a/src/testdir/test_textobjects.vim +++ b/src/testdir/test_textobjects.vim @@ -4,7 +4,6 @@ if !has('textobjects') finish endif -set belloff=all func CpoM(line, useM, expected) new diff --git a/src/testdir/test_undo.vim b/src/testdir/test_undo.vim index e785c605da..06732af715 100644 --- a/src/testdir/test_undo.vim +++ b/src/testdir/test_undo.vim @@ -3,7 +3,6 @@ " undo-able pieces. Do that by setting 'undolevels'. " Also tests :earlier and :later. -set belloff=all func Test_undotree() exe "normal Aabc\" set ul=100 diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim index 29db51f0a6..9420321ac9 100644 --- a/src/testdir/test_usercommands.vim +++ b/src/testdir/test_usercommands.vim @@ -1,7 +1,6 @@ " Tests for user defined commands " Test for in user defined commands -set belloff=all function Test_cmdmods() let g:mods = '' diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim index e4bd10079b..0e6231fd6d 100644 --- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -3,7 +3,6 @@ if !has('visual') finish endif -set belloff=all func Test_block_shift_multibyte() " Uses double-wide character. @@ -76,7 +75,6 @@ func TriggerTheProblem() endfunc func Test_visual_mode_reset() - set belloff=all enew let g:msg="Everything's fine." enew @@ -89,5 +87,5 @@ func Test_visual_mode_reset() exe "normal! GV:call TriggerTheProblem()\" call assert_equal("Everything's fine.", g:msg) - set belloff& endfunc + diff --git a/src/testdir/test_winbuf_close.vim b/src/testdir/test_winbuf_close.vim new file mode 100644 index 0000000000..ed64dd79b7 --- /dev/null +++ b/src/testdir/test_winbuf_close.vim @@ -0,0 +1,124 @@ +" Test for commands that close windows and/or buffers: +" :quit +" :close +" :hide +" :only +" :sall +" :all +" :ball +" :buf +" :edit +" +func Test_winbuf_close() + enew | only + + call writefile(['testtext 1'], 'Xtest1') + call writefile(['testtext 2'], 'Xtest2') + call writefile(['testtext 3'], 'Xtest3') + + next! Xtest1 Xtest2 + call setline(1, 'testtext 1 1') + + " test for working :n when hidden set + set hidden + next + call assert_equal('Xtest2', bufname('%')) + + " test for failing :rew when hidden not set + set nohidden + call setline(1, 'testtext 2 2') + call assert_fails('rewind', 'E37') + call assert_equal('Xtest2', bufname('%')) + call assert_equal('testtext 2 2', getline(1)) + + " test for working :rew when hidden set + set hidden + rewind + call assert_equal('Xtest1', bufname('%')) + call assert_equal('testtext 1 1', getline(1)) + + " test for :all keeping a buffer when it's modified + set nohidden + call setline(1, 'testtext 1 1 1') + split + next Xtest2 Xtest3 + all + 1wincmd w + call assert_equal('Xtest1', bufname('%')) + call assert_equal('testtext 1 1 1', getline(1)) + + " test abandoning changed buffer, should be unloaded even when 'hidden' set + set hidden + call setline(1, 'testtext 1 1 1 1') + quit! + call assert_equal('Xtest2', bufname('%')) + call assert_equal('testtext 2 2', getline(1)) + unhide + call assert_equal('Xtest2', bufname('%')) + call assert_equal('testtext 2 2', getline(1)) + + " test ":hide" hides anyway when 'hidden' not set + set nohidden + call setline(1, 'testtext 2 2 2') + hide + call assert_equal('Xtest3', bufname('%')) + call assert_equal('testtext 3', getline(1)) + + " test ":edit" failing in modified buffer when 'hidden' not set + call setline(1, 'testtext 3 3') + call assert_fails('edit Xtest1', 'E37') + call assert_equal('Xtest3', bufname('%')) + call assert_equal('testtext 3 3', getline(1)) + + " test ":edit" working in modified buffer when 'hidden' set + set hidden + edit Xtest1 + call assert_equal('Xtest1', bufname('%')) + call assert_equal('testtext 1', getline(1)) + + " test ":close" not hiding when 'hidden' not set in modified buffer + split Xtest3 + set nohidden + call setline(1, 'testtext 3 3 3') + call assert_fails('close', 'E37') + call assert_equal('Xtest3', bufname('%')) + call assert_equal('testtext 3 3 3', getline(1)) + + " test ":close!" does hide when 'hidden' not set in modified buffer; + call setline(1, 'testtext 3 3 3 3') + close! + call assert_equal('Xtest1', bufname('%')) + call assert_equal('testtext 1', getline(1)) + + set nohidden + + " test ":all!" hides changed buffer + split Xtest4 + call setline(1, 'testtext 4') + all! + 1wincmd w + call assert_equal('Xtest2', bufname('%')) + call assert_equal('testtext 2 2 2', getline(1)) + + " test ":q!" and hidden buffer. + bwipe! Xtest1 Xtest2 Xtest3 Xtest4 + split Xtest1 + wincmd w + bwipe! + set modified + bot split Xtest2 + set modified + bot split Xtest3 + set modified + wincmd t + hide + call assert_equal('Xtest2', bufname('%')) + quit! + call assert_equal('Xtest3', bufname('%')) + call assert_fails('silent! quit!', 'E162') + call assert_equal('Xtest1', bufname('%')) + + call delete('Xtest1') + call delete('Xtest2') + call delete('Xtest3') +endfunc diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim index 6768e3154a..f462d049c0 100644 --- a/src/testdir/test_writefile.vim +++ b/src/testdir/test_writefile.vim @@ -49,3 +49,47 @@ func Test_writefile_fails_conversion() bwipe! set backup& writebackup& endfunc + +func SetFlag(timer) + let g:flag = 1 +endfunc + +func Test_write_quit_split() + " Prevent exiting by splitting window on file write. + augroup testgroup + autocmd BufWritePre * split + augroup END + e! Xfile + call setline(1, 'nothing') + wq + + if has('timers') + " timer will not run if "exiting" is still set + let g:flag = 0 + call timer_start(1, 'SetFlag') + sleep 50m + call assert_equal(1, g:flag) + unlet g:flag + endif + au! testgroup + bwipe Xfile + call delete('Xfile') +endfunc + +func Test_nowrite_quit_split() + " Prevent exiting by opening a help window. + e! Xfile + help + wincmd w + exe winnr() . 'q' + + if has('timers') + " timer will not run if "exiting" is still set + let g:flag = 0 + call timer_start(1, 'SetFlag') + sleep 50m + call assert_equal(1, g:flag) + unlet g:flag + endif + bwipe Xfile +endfunc diff --git a/src/uninstal.c b/src/uninstal.c index f39411723a..11b6c629ad 100644 --- a/src/uninstal.c +++ b/src/uninstal.c @@ -32,10 +32,8 @@ confirm(void) return (scanf(" %c", answer) == 1 && toupper(answer[0]) == 'Y'); } -#ifdef WIN3264 - static int -reg_delete_key(HKEY hRootKey, const char *key) +reg_delete_key(HKEY hRootKey, const char *key, DWORD flag) { static int did_load = FALSE; static HANDLE advapi_lib = NULL; @@ -52,7 +50,7 @@ reg_delete_key(HKEY hRootKey, const char *key) delete_key_ex = (LONG (WINAPI *)(HKEY, LPCTSTR, REGSAM, DWORD))GetProcAddress(advapi_lib, "RegDeleteKeyExA"); } if (delete_key_ex != NULL) { - return (*delete_key_ex)(hRootKey, key, KEY_WOW64_64KEY, 0); + return (*delete_key_ex)(hRootKey, key, flag, 0); } return RegDeleteKey(hRootKey, key); } @@ -72,7 +70,9 @@ popup_gvim_path(char *buf) /* Open the key where the path to gvim.exe is stored. */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0, KEY_WOW64_64KEY | KEY_READ, &key_handle) != ERROR_SUCCESS) - return 0; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0, + KEY_WOW64_32KEY | KEY_READ, &key_handle) != ERROR_SUCCESS) + return 0; /* get the DisplayName out of it to show the user */ r = RegQueryValueEx(key_handle, "path", 0, @@ -111,29 +111,41 @@ openwith_gvim_path(char *buf) remove_popup(void) { int fail = 0; + int i; + int loop = is_64bit_os() ? 2 : 1; + int maxfail = loop * 6; + DWORD flag; HKEY kh; - if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\\InProcServer32") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\gvim") != ERROR_SUCCESS) - ++fail; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, - KEY_WOW64_64KEY | KEY_ALL_ACCESS, &kh) != ERROR_SUCCESS) - ++fail; - else + for (i = 0; i < loop; i++) { - if (RegDeleteValue(kh, "{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS) - ++fail; - RegCloseKey(kh); - } - if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim") != ERROR_SUCCESS) - ++fail; + if (i == 0) + flag = KEY_WOW64_32KEY; + else + flag = KEY_WOW64_64KEY; - if (fail == 6) + if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\\InProcServer32", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\gvim", flag) != ERROR_SUCCESS) + ++fail; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, + flag | KEY_ALL_ACCESS, &kh) != ERROR_SUCCESS) + ++fail; + else + { + if (RegDeleteValue(kh, "{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS) + ++fail; + RegCloseKey(kh); + } + if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim", flag) != ERROR_SUCCESS) + ++fail; + } + + if (fail == maxfail) printf("No Vim popup registry entries could be removed\n"); else if (fail > 0) printf("Some Vim popup registry entries could not be removed\n"); @@ -145,30 +157,41 @@ remove_popup(void) remove_openwith(void) { int fail = 0; + int i; + int loop = is_64bit_os() ? 2 : 1; + int maxfail = loop * 7; + DWORD flag; - if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, ".htm\\OpenWithList\\gvim.exe") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, ".vim\\OpenWithList\\gvim.exe") != ERROR_SUCCESS) - ++fail; - if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\OpenWithList\\gvim.exe") != ERROR_SUCCESS) - ++fail; + for (i = 0; i < loop; i++) + { + if (i == 0) + flag = KEY_WOW64_32KEY; + else + flag = KEY_WOW64_64KEY; - if (fail == 7) + if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, ".htm\\OpenWithList\\gvim.exe", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, ".vim\\OpenWithList\\gvim.exe", flag) != ERROR_SUCCESS) + ++fail; + if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\OpenWithList\\gvim.exe", flag) != ERROR_SUCCESS) + ++fail; + } + + if (fail == maxfail) printf("No Vim open-with registry entries could be removed\n"); else if (fail > 0) printf("Some Vim open-with registry entries could not be removed\n"); else printf("The Vim open-with registry entries have been removed\n"); } -#endif /* * Check if a batch file is really for the current version. Don't delete a @@ -231,7 +254,6 @@ remove_batfiles(int doit) return found; } -#ifdef WIN3264 static void remove_if_exists(char *path, char *filename) { @@ -284,12 +306,11 @@ remove_start_menu(void) } } } -#endif static void delete_uninstall_key(void) { - reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT); + reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT, KEY_WOW64_64KEY); } int @@ -297,7 +318,6 @@ main(int argc, char *argv[]) { int found = 0; FILE *fd; -#ifdef WIN3264 int i; struct stat st; char icon[BUFSIZE]; @@ -308,7 +328,6 @@ main(int argc, char *argv[]) if (argc == 2 && stricmp(argv[1], "-nsis") == 0) interactive = FALSE; else -#endif interactive = TRUE; /* Initialize this program. */ @@ -316,7 +335,6 @@ main(int argc, char *argv[]) printf("This program will remove the following items:\n"); -#ifdef WIN3264 if (popup_gvim_path(popup_path)) { printf(" - the \"Edit with Vim\" entry in the popup menu\n"); @@ -370,7 +388,6 @@ main(int argc, char *argv[]) if (!interactive || confirm()) remove_start_menu(); } -#endif printf("\n"); found = remove_batfiles(0); diff --git a/src/version.c b/src/version.c index 83946fe085..cdda66641f 100644 --- a/src/version.c +++ b/src/version.c @@ -776,6 +776,62 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1203, +/**/ + 1202, +/**/ + 1201, +/**/ + 1200, +/**/ + 1199, +/**/ + 1198, +/**/ + 1197, +/**/ + 1196, +/**/ + 1195, +/**/ + 1194, +/**/ + 1193, +/**/ + 1192, +/**/ + 1191, +/**/ + 1190, +/**/ + 1189, +/**/ + 1188, +/**/ + 1187, +/**/ + 1186, +/**/ + 1185, +/**/ + 1184, +/**/ + 1183, +/**/ + 1182, +/**/ + 1181, +/**/ + 1180, +/**/ + 1179, +/**/ + 1178, +/**/ + 1177, +/**/ + 1176, /**/ 1175, /**/ diff --git a/src/vim.h b/src/vim.h index 848abf021f..c15b838d5f 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2001,11 +2001,12 @@ typedef int sock_T; #define VV_TYPE_NONE 78 #define VV_TYPE_JOB 79 #define VV_TYPE_CHANNEL 80 -#define VV_TERMRGBRESP 81 -#define VV_TERMU7RESP 82 -#define VV_TERMSTYLERESP 83 -#define VV_TERMBLINKRESP 84 -#define VV_LEN 85 /* number of v: vars */ +#define VV_TERMRFGRESP 81 +#define VV_TERMRBGRESP 82 +#define VV_TERMU7RESP 83 +#define VV_TERMSTYLERESP 84 +#define VV_TERMBLINKRESP 85 +#define VV_LEN 86 /* number of v: vars */ /* used for v_number in VAR_SPECIAL */ #define VVAL_FALSE 0L diff --git a/src/xxd/Make_mvc.mak b/src/xxd/Make_mvc.mak index 3227f0c864..0133d73115 100644 --- a/src/xxd/Make_mvc.mak +++ b/src/xxd/Make_mvc.mak @@ -1,14 +1,19 @@ # The most simplistic Makefile for Win32 using Microsoft Visual C++ # (NT and Windows 95) +SUBSYSTEM = console +!if "$(SUBSYSTEM_VER)" != "" +SUBSYSTEM = $(SUBSYSTEM),$(SUBSYSTEM_VER) +!endif + xxd: xxd.exe xxd.exe: xxd.c - cl /nologo -DWIN32 xxd.c + cl /nologo -DWIN32 xxd.c -link -subsystem:$(SUBSYSTEM) # This was for an older compiler # cl /nologo -DWIN32 xxd.c /link setargv.obj clean: - - if exist xxd.obj del xxd.obj - - if exist xxd.exe del xxd.exe + - if exist xxd.obj del xxd.obj + - if exist xxd.exe del xxd.exe