From 20070310a43a8ddb76ea67bd4c50aa7c4dce54f9 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 27 Aug 2020 20:01:14 +0200 Subject: [PATCH 1/5] bump libvterm to 0.1.4 --- third-party/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 4cd18efcf3..a31bd88189 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -160,8 +160,8 @@ set(UNIBILIUM_SHA256 29815283c654277ef77a3adcc8840db79ddbb20a0f0b0c8f648bd8cd49a set(LIBTERMKEY_URL http://www.leonerd.org.uk/code/libtermkey/libtermkey-0.21.1.tar.gz) set(LIBTERMKEY_SHA256 cecbf737f35d18f433c8d7864f63c0f878af41f8bd0255a3ebb16010dc044d5f) -set(LIBVTERM_URL https://github.com/neovim/libvterm/archive/7c72294d84ce20da4c27362dbd7fa4b08cfc91da.tar.gz) -set(LIBVTERM_SHA256 f30c4d43e0c6db3e0912daf7188d98fbf6ee88f97589d72f6f304e5db48826a8) +set(LIBVTERM_URL http://www.leonerd.org.uk/code/libvterm/libvterm-0.1.4.tar.gz) +set(LIBVTERM_SHA256 bc70349e95559c667672fc8c55b9527d9db9ada0fb80a3beda533418d782d3dd) set(LUV_VERSION 1.30.0-0) set(LUV_URL https://github.com/luvit/luv/archive/${LUV_VERSION}.tar.gz) From b92399d00864a3317dbdac3aec8ccb8fec670c9f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 10 Oct 2019 04:16:02 -0400 Subject: [PATCH 2/5] doc: update shellquote for powershell #11122 shellquote is not treated like shellxquote for non-quote values. --- runtime/doc/options.txt | 2 +- test/functional/helpers.lua | 15 +++++++++++++-- test/functional/ui/output_spec.lua | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 525475b60b..a81d01b3d6 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5169,7 +5169,7 @@ A jump table for the options with a short description can be found at |Q_op|. unescaping, so to keep yourself sane use |:let-&| like shown above. *shell-powershell* To use powershell (on Windows): > - set shell=powershell shellquote=( shellpipe=\| shellxquote= + set shell=powershell shellquote= shellpipe=\| shellxquote= set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command set shellredir=\|\ Out-File\ -Encoding\ UTF8 diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index bd36bac062..dbaedd6f60 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -500,9 +500,20 @@ function module.source(code) end function module.set_shell_powershell() + local shell = iswin() and 'powershell' or 'pwsh' + if not module.eval('executable("'..shell..'")') then + error(shell..' is not executable') + end + local aliases = iswin() and {'cat', 'sleep'} or {} + local cmd = '' + for _, alias in ipairs(aliases) do + cmd = cmd .. 'Remove-Item -Force alias:' .. alias .. ';' + end module.source([[ - set shell=powershell shellquote=( shellpipe=\| shellredir=> shellxquote= - let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command Remove-Item -Force alias:sleep; Remove-Item -Force alias:cat;' + let &shell = ']]..shell..[[' + set shellquote= shellpipe=\| shellxquote= + let &shellredir = '| Out-File -Encoding UTF8' + let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ]]..cmd..[[' ]]) end diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index c028f44b44..c5d3e536ad 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -10,6 +10,7 @@ local iswin = helpers.iswin local clear = helpers.clear local command = helpers.command local nvim_dir = helpers.nvim_dir +local set_shell_powershell = helpers.set_shell_powershell describe("shell command :!", function() local screen @@ -230,4 +231,19 @@ describe("shell command :!", function() ]]) end) end) + if iswin() or eval('executable("pwsh")') == 1 then + it('powershell supports literal strings', function() + set_shell_powershell() + local screen = Screen.new(30, 4) + screen:attach() + feed_command([[!'echo $a']]) + screen:expect{any='\necho %$a', timeout=10000} + feed_command([[!$a = 1; echo '$a']]) + screen:expect{any='\n%$a', timeout=10000} + feed_command([[!"echo $a"]]) + screen:expect{any='\necho', timeout=10000} + feed_command([[!$a = 1; echo "$a"]]) + screen:expect{any='\n1', timeout=10000} + end) + end end) From 1c3afe4e2542128dcb695f9d6a77e6f1de2c7ce3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 31 Dec 2019 22:29:40 -0500 Subject: [PATCH 3/5] doc: powershell is 'pwsh' on non-Windows OS --- runtime/doc/options.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index a81d01b3d6..e9e2516d58 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5168,8 +5168,9 @@ A jump table for the options with a short description can be found at |Q_op|. Note that such processing is done after |:set| did its own round of unescaping, so to keep yourself sane use |:let-&| like shown above. *shell-powershell* - To use powershell (on Windows): > - set shell=powershell shellquote= shellpipe=\| shellxquote= + To use powershell: > + let &shell = has('win32') ? 'powershell' : 'pwsh' + set shellquote= shellpipe=\| shellxquote= set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command set shellredir=\|\ Out-File\ -Encoding\ UTF8 From 1de33ce2cdd4ef4412ee9758027c87d94072ac84 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 24 Jul 2020 22:39:12 +0200 Subject: [PATCH 4/5] build: remove duplicate empty CONFIGURE_COMMAND (#12676) The cmake file for libvterm had an empty CONFIGURE_COMMAND "", which tells cmake to skip the configure step for this dependency (even though a later patch added another, actual, CONFIGURE_COMMAND two lines below). Evidently the recently released cmake 3.18.0 is pickier about this than previous versions, causing the build to fail. Removing this line makes the build successful again. --- third-party/cmake/BuildLibvterm.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/third-party/cmake/BuildLibvterm.cmake b/third-party/cmake/BuildLibvterm.cmake index 61c1c90fa6..c3485dac25 100644 --- a/third-party/cmake/BuildLibvterm.cmake +++ b/third-party/cmake/BuildLibvterm.cmake @@ -27,7 +27,6 @@ function(BuildLibvterm) -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake PATCH_COMMAND "${_libvterm_PATCH_COMMAND}" - CONFIGURE_COMMAND "" BUILD_IN_SOURCE 1 CONFIGURE_COMMAND "${_libvterm_CONFIGURE_COMMAND}" BUILD_COMMAND "${_libvterm_BUILD_COMMAND}" From b2cef8b6650627f65c43029645942d46103a77df Mon Sep 17 00:00:00 2001 From: erw7 Date: Tue, 28 Jul 2020 00:51:41 +0900 Subject: [PATCH 5/5] terminal: fix terminal attribute overflow fixes #11548 --- src/nvim/screen.c | 6 +++--- src/nvim/screen.h | 3 +++ src/nvim/terminal.c | 1 + test/functional/terminal/buffer_spec.lua | 9 +++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 4b4b2c416f..05e3d90c8f 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2692,8 +2692,8 @@ win_line ( off += col; } - // wont highlight after 1024 columns - int term_attrs[1024] = {0}; + // wont highlight after TERM_ATTRS_MAX columns + int term_attrs[TERM_ATTRS_MAX] = { 0 }; if (wp->w_buffer->terminal) { terminal_get_line_attributes(wp->w_buffer->terminal, wp, lnum, term_attrs); extra_check = true; @@ -4030,7 +4030,7 @@ win_line ( int n = wp->w_p_rl ? -1 : 1; while (col >= 0 && col < grid->Columns) { schar_from_ascii(linebuf_char[off], ' '); - linebuf_attr[off] = term_attrs[vcol]; + linebuf_attr[off] = vcol >= TERM_ATTRS_MAX ? 0 : term_attrs[vcol]; off += n; vcol += n; col += n; diff --git a/src/nvim/screen.h b/src/nvim/screen.h index 61ed98247d..754ab06bec 100644 --- a/src/nvim/screen.h +++ b/src/nvim/screen.h @@ -32,6 +32,9 @@ EXTERN ScreenGrid default_grid INIT(= SCREEN_GRID_INIT); #define DEFAULT_GRID_HANDLE 1 // handle for the default_grid +// Maximum columns for terminal highlight attributes +#define TERM_ATTRS_MAX 1024 + /// Status line click definition typedef struct { enum { diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 7609006906..3de6f19cda 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -588,6 +588,7 @@ void terminal_get_line_attributes(Terminal *term, win_T *wp, int linenr, return; } + width = MIN(TERM_ATTRS_MAX, width); for (int col = 0; col < width; col++) { VTermScreenCell cell; bool color_valid = fetch_cell(term, row, col, &cell); diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index c6ea0c0e6b..fb6e0d0e94 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -264,3 +264,12 @@ describe('No heap-buffer-overflow when using', function() feed_command('bdelete!') end) end) + +describe('No heap-buffer-overflow when', function() + it('set nowrap and send long line #11548', function() + feed_command('set nowrap') + feed_command('autocmd TermOpen * startinsert') + feed_command('call feedkeys("4000ai\\:terminal!\\")') + eq(2, eval('1+1')) + end) +end)