Compare commits

...

2 Commits

Author SHA1 Message Date
Foxe Chen
11c3c62aa8 patch 9.1.2014: clipboard: clipboard register corrupted with clipboard provider
Problem:  clipboard: clipboard register corrupted with clipboard
          provider (Satoru Kitaguchi and mikoto2000 after v9.1.1972)
Solution: Only adjust clipboard register points to the unnamed register
          (Foxe Chen)

fixes:  #18983
fixes:  #18988
closes: #19000

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-23 20:29:08 +00:00
Muraoka Taro
90e17110c4 patch 9.1.2013: tests: Test_terminal_shell_option fails with conpty
Problem:  tests: When opening a conpty terminal, if process startup
          fails, it will silently exit.  As a result, the
          Test_terminal_shell_option in test_terminal3.vim failed in
          conpty.

          In a winpty terminal, the winpty-provided error message
          "CreateProcess failed" was displayed.  The test is designed to
          catch this error as an exception.

Solution: Make conpty fail with an error messages in the same way as winpty.
          (Muraoka Taro)

In addition, since the GetWin32Error() function can obtain more detailed
error messages, the format has been changed to "CreateProcess failed:
{localized message from the OS}" for conpty.

Also, since the GetWin32Error() function returns errors in ACP (Active
Code Page) encoding, these have been converted to Vim's internal
encoding, enc.  This will prevent messages from being garbled in
Japanese environments, etc.  The output of this function was basically
used by the semsg() function in other places, so this change also fixes
potential similar garbled characters.

The test now errors out immediately in places where it is expected not
to be reached, and comments have been added about the expected content
of the winpty and conpty error messages.

closes: #18998

Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-23 20:22:54 +00:00
6 changed files with 44 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
*options.txt* For Vim version 9.1. Last change: 2025 Dec 21
*options.txt* For Vim version 9.1. Last change: 2025 Dec 23
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1823,7 +1823,7 @@ A jump table for the options with a short description can be found at |Q_op|.
prepend, e.g.: >
set clipboard^=unnamed
< When using the GUI see |'go-A'|.
When using the |clipboard-providers| feature, only the "unamed" and
When using the |clipboard-providers| feature, only the "unnamed" and
"unnamedplus" features will be recognized If compiled without the
|+clipboard| feature but compiled with the |+clipboard_provider|
feature, then they will be the only values allowed and the other

View File

@@ -3534,7 +3534,7 @@ adjust_clip_reg(int *rp)
#ifdef FEAT_CLIPBOARD_PROVIDER
if (clipmethod == CLIPMETHOD_PROVIDER)
{
if (clip_unnamed != 0)
if (*rp == 0 && clip_unnamed != 0)
*rp = ((clip_unnamed & CLIP_UNNAMED_PLUS)) ? '+' : '*';
return;
}

View File

@@ -9074,22 +9074,38 @@ resize_console_buf(void)
char *
GetWin32Error(void)
{
static char *oldmsg = NULL;
char *msg = NULL;
static char *oldmsg = NULL;
char *acp_msg = NULL;
DWORD acp_len;
char_u *enc_msg = NULL;
int enc_len = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
// get formatted message from OS
acp_len = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(), 0, (LPSTR)&acp_msg, 0, NULL);
if (acp_len == 0 || acp_msg == NULL)
return NULL;
// clean oldmsg if remained.
if (oldmsg != NULL)
LocalFree(oldmsg);
if (msg == NULL)
{
vim_free(oldmsg);
oldmsg = NULL;
}
acp_to_enc(acp_msg, (int)acp_len, &enc_msg, &enc_len);
LocalFree(acp_msg);
if (enc_msg == NULL)
return NULL;
// remove trailing \r\n
char *pcrlf = strstr(msg, "\r\n");
char *pcrlf = strstr(enc_msg, "\r\n");
if (pcrlf != NULL)
*pcrlf = NUL;
oldmsg = msg;
return msg;
oldmsg = enc_msg;
return enc_msg;
}
#if defined(FEAT_RELTIME)

View File

@@ -7048,6 +7048,7 @@ conpty_term_and_job_init(
HANDLE o_theirs = NULL;
HANDLE i_ours = NULL;
HANDLE o_ours = NULL;
char *errmsg = NULL;
ga_init2(&ga_cmd, sizeof(char*), 20);
ga_init2(&ga_env, sizeof(char*), 20);
@@ -7149,7 +7150,10 @@ conpty_term_and_job_init(
| CREATE_SUSPENDED | CREATE_DEFAULT_ERROR_MODE,
env_wchar, cwd_wchar,
&term->tl_siex.StartupInfo, &proc_info))
{
errmsg = GetWin32Error();
goto failed;
}
CloseHandle(i_theirs);
CloseHandle(o_theirs);
@@ -7257,6 +7261,9 @@ failed:
if (term->tl_conpty != NULL)
pClosePseudoConsole(term->tl_conpty);
term->tl_conpty = NULL;
// Propagate errors that occur in CreateProcess
if (errmsg)
semsg("CreateProcess failed: %s", errmsg);
return FAIL;
}

View File

@@ -46,9 +46,11 @@ func Test_terminal_shell_option()
" the %PATH%, "term dir" succeeds unintentionally. Use dir.com instead.
try
term dir.com /b runtest.vim
call WaitForAssert({-> assert_match('job failed', term_getline(bufnr(), 1))})
catch /CreateProcess/
" ignore
throw 'dir.com without a shell must fail, so you will never get here'
catch /CreateProcess failed/
" ignore:
" winpty simply fails with "CreateProcess failed".
" compty fails with "CreateProcess failed: {localized failure reason}".
endtry
bwipe!

View File

@@ -734,6 +734,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2014,
/**/
2013,
/**/
2012,
/**/