From: Foxe Chen Date: Tue, 16 Dec 2025 19:35:53 +0000 (+0100) Subject: patch 9.1.1988: osc52 package can be further improved X-Git-Tag: v9.1.1988^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9e45e82ba1d81f86183be1e8b7f004682fc3533;p=thirdparty%2Fvim.git patch 9.1.1988: osc52 package can be further improved Problem: osc52 package can be further improved (after v9.1.1984). Solution: Improve plugin, update test and check for clipboard_provider feature (Foxe Chen). closes: #18935 Signed-off-by: Foxe Chen Signed-off-by: Christian Brabandt --- diff --git a/runtime/pack/dist/opt/osc52/autoload/osc52.vim b/runtime/pack/dist/opt/osc52/autoload/osc52.vim index bd664f17c8..28c49accf9 100644 --- a/runtime/pack/dist/opt/osc52/autoload/osc52.vim +++ b/runtime/pack/dist/opt/osc52/autoload/osc52.vim @@ -67,18 +67,23 @@ export def Paste(reg: string): tuple> endif # Extract the base64 stuff - var stuff: string = matchstr(v:termosc, '52;.\+;\zs[A-Za-z0-9+/=]\+') - var decoded: blob + var stuff: string = matchstr(v:termosc, '52;.*;\zs[A-Za-z0-9+/=]*') + + if len(stuff) == 0 + return ("c", []) + endif + + var ret: list # "stuff" may be an invalid base64 string, so catch any errors try - decoded = base64_decode(stuff) - catch /:E475/ - decoded = null_blob + ret = blob2str(base64_decode(stuff)) + catch /E\(475\|1515\)/ echo "Invalid OSC 52 response received" + return ("c", [""]) endtry - return ("", blob2str(decoded)) + return ("", ret) enddef export def Copy(reg: string, type: string, lines: list): void diff --git a/runtime/pack/dist/opt/osc52/plugin/osc52.vim b/runtime/pack/dist/opt/osc52/plugin/osc52.vim index ddec41ed17..7801ef64e5 100644 --- a/runtime/pack/dist/opt/osc52/plugin/osc52.vim +++ b/runtime/pack/dist/opt/osc52/plugin/osc52.vim @@ -3,7 +3,7 @@ vim9script # Vim plugin for OSC52 clipboard support # # Maintainer: The Vim Project -# Last Change: 2025 October 14 +# Last Change: 2025 Dec 16 if !has("timers") finish @@ -37,6 +37,7 @@ augroup VimOSC52Plugin } autocmd VimEnter * { if !has("gui_running") && !get(g:, 'osc52_force_avail', 0) + && !get(g:, 'osc52_no_da1', 0) echoraw("\[c") endif } diff --git a/src/testdir/test_plugin_osc52.vim b/src/testdir/test_plugin_osc52.vim index fff40936ad..f14d3b8c16 100644 --- a/src/testdir/test_plugin_osc52.vim +++ b/src/testdir/test_plugin_osc52.vim @@ -1,14 +1,14 @@ " Test for the OSC 52 plugin +CheckFeature clipboard_provider CheckRunVimInTerminal -" Does not run on BSD CI test runner -CheckNotBSD source util/screendump.vim " Check if plugin correctly detects OSC 52 support if possible func Test_osc52_detect() let lines =<< trim END + let g:osc52_no_da1 = 1 packadd osc52 set clipmethod=osc52 END @@ -46,6 +46,7 @@ func Test_osc52_paste() CheckScreendump let lines =<< trim END + let g:osc52_no_da1 = 1 packadd osc52 set clipmethod=osc52 redraw! diff --git a/src/version.c b/src/version.c index a4d7a1bf74..64a2cc03bd 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1988, /**/ 1987, /**/