0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.3243: MS-Windows: "edit with multiple Vim" choice is less useful

Problem:    MS-Windows: the "edit with multiple Vim" choice is not that
            useful.
Solution:   Change it to "Edit with multiple tabs". (Michael Soyka,
            closes #8645)
This commit is contained in:
msoyka-of-wharton 2021-07-29 19:18:33 +02:00 committed by Bram Moolenaar
parent 0732932553
commit 83cd0156e0
3 changed files with 34 additions and 96 deletions

View File

@ -35,6 +35,15 @@ UINT cbFiles = 0;
* enough */ * enough */
#define BUFSIZE 1100 #define BUFSIZE 1100
// The "Edit with Vim" shell extension provides these choices when
// a new instance of Gvim is selected:
// - use tabpages
// - enable diff mode
// - none of the above
#define EDIT_WITH_VIM_USE_TABPAGES (2)
#define EDIT_WITH_VIM_IN_DIFF_MODE (1)
#define EDIT_WITH_VIM_NO_OPTIONS (0)
// //
// Get the name of the Gvim executable to use, with the path. // Get the name of the Gvim executable to use, with the path.
// When "runtime" is non-zero, we were called to find the runtime directory. // When "runtime" is non-zero, we were called to find the runtime directory.
@ -613,7 +622,7 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
if (cbFiles > 1) if (cbFiles > 1)
{ {
mii.wID = idCmd++; mii.wID = idCmd++;
mii.dwTypeData = _("Edit with &multiple Vims"); mii.dwTypeData = _("Edit with Vim using &tabpages");
mii.cch = lstrlen(mii.dwTypeData); mii.cch = lstrlen(mii.dwTypeData);
InsertMenuItem(hMenu, indexMenu++, TRUE, &mii); InsertMenuItem(hMenu, indexMenu++, TRUE, &mii);
@ -726,6 +735,7 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{ {
HRESULT hr = E_INVALIDARG; HRESULT hr = E_INVALIDARG;
int gvimExtraOptions;
// If HIWORD(lpcmi->lpVerb) then we have been called programmatically // If HIWORD(lpcmi->lpVerb) then we have been called programmatically
// and lpVerb is a command that should be invoked. Otherwise, the shell // and lpVerb is a command that should be invoked. Otherwise, the shell
@ -750,29 +760,28 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
switch (idCmd) switch (idCmd)
{ {
case 0: case 0:
hr = InvokeGvim(lpcmi->hwnd, gvimExtraOptions = EDIT_WITH_VIM_USE_TABPAGES;
lpcmi->lpDirectory,
lpcmi->lpVerb,
lpcmi->lpParameters,
lpcmi->nShow);
break; break;
case 1: case 1:
hr = InvokeSingleGvim(lpcmi->hwnd, gvimExtraOptions = EDIT_WITH_VIM_NO_OPTIONS;
lpcmi->lpDirectory,
lpcmi->lpVerb,
lpcmi->lpParameters,
lpcmi->nShow,
0);
break; break;
case 2: case 2:
hr = InvokeSingleGvim(lpcmi->hwnd, gvimExtraOptions = EDIT_WITH_VIM_IN_DIFF_MODE;
lpcmi->lpDirectory,
lpcmi->lpVerb,
lpcmi->lpParameters,
lpcmi->nShow,
1);
break; break;
default:
// If execution reaches this point we likely have an
// inconsistency between the code that setup the menus
// and this code that determines what the user
// selected. This should be detected and fixed during
// development.
return E_FAIL;
} }
hr = InvokeSingleGvim(lpcmi->hwnd,
lpcmi->lpDirectory,
lpcmi->lpVerb,
lpcmi->lpParameters,
lpcmi->nShow,
gvimExtraOptions);
} }
} }
return hr; return hr;
@ -873,82 +882,13 @@ searchpath(char *name)
return (char *)""; return (char *)"";
} }
STDMETHODIMP CShellExt::InvokeGvim(HWND hParent,
LPCSTR /* pszWorkingDir */,
LPCSTR /* pszCmd */,
LPCSTR /* pszParam */,
int /* iShowCmd */)
{
wchar_t m_szFileUserClickedOn[BUFSIZE];
wchar_t cmdStrW[BUFSIZE];
UINT i;
for (i = 0; i < cbFiles; i++)
{
DragQueryFileW((HDROP)medium.hGlobal,
i,
m_szFileUserClickedOn,
sizeof(m_szFileUserClickedOn));
getGvimInvocationW(cmdStrW);
wcscat(cmdStrW, L" \"");
if ((wcslen(cmdStrW) + wcslen(m_szFileUserClickedOn) + 2) < BUFSIZE)
{
wcscat(cmdStrW, m_szFileUserClickedOn);
wcscat(cmdStrW, L"\"");
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
// Start the child process.
if (!CreateProcessW(NULL, // No module name (use command line).
cmdStrW, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
)
{
MessageBox(
hParent,
_("Error creating process: Check if gvim is in your path!"),
_("gvimext.dll error"),
MB_OK);
}
else
{
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
}
else
{
MessageBox(
hParent,
_("Path length too long!"),
_("gvimext.dll error"),
MB_OK);
}
}
return NOERROR;
}
STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent, STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
LPCSTR /* pszWorkingDir */, LPCSTR /* pszWorkingDir */,
LPCSTR /* pszCmd */, LPCSTR /* pszCmd */,
LPCSTR /* pszParam */, LPCSTR /* pszParam */,
int /* iShowCmd */, int /* iShowCmd */,
int useDiff) int gvimExtraOptions)
{ {
wchar_t m_szFileUserClickedOn[BUFSIZE]; wchar_t m_szFileUserClickedOn[BUFSIZE];
wchar_t *cmdStrW; wchar_t *cmdStrW;
@ -962,8 +902,10 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
return E_FAIL; return E_FAIL;
getGvimInvocationW(cmdStrW); getGvimInvocationW(cmdStrW);
if (useDiff) if (gvimExtraOptions == EDIT_WITH_VIM_IN_DIFF_MODE)
wcscat(cmdStrW, L" -d"); wcscat(cmdStrW, L" -d");
else if (gvimExtraOptions == EDIT_WITH_VIM_USE_TABPAGES)
wcscat(cmdStrW, L" -p");
for (i = 0; i < cbFiles; i++) for (i = 0; i < cbFiles; i++)
{ {
DragQueryFileW((HDROP)medium.hGlobal, DragQueryFileW((HDROP)medium.hGlobal,

View File

@ -129,18 +129,12 @@ protected:
int iShowCmd, int iShowCmd,
int idHWnd); int idHWnd);
STDMETHODIMP InvokeGvim(HWND hParent,
LPCSTR pszWorkingDir,
LPCSTR pszCmd,
LPCSTR pszParam,
int iShowCmd);
STDMETHODIMP InvokeSingleGvim(HWND hParent, STDMETHODIMP InvokeSingleGvim(HWND hParent,
LPCSTR pszWorkingDir, LPCSTR pszWorkingDir,
LPCSTR pszCmd, LPCSTR pszCmd,
LPCSTR pszParam, LPCSTR pszParam,
int iShowCmd, int iShowCmd,
int useDiff); int gvimExtraOptions);
public: public:
int m_cntOfHWnd; int m_cntOfHWnd;

View File

@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3243,
/**/ /**/
3242, 3242,
/**/ /**/