Skip to content

Commit

Permalink
Add better error message and actions when current directory is empty …
Browse files Browse the repository at this point in the history
…("new-1" file)

Alt-shortcuts for Settings dialog
Minimize panel borders
  • Loading branch information
VinsWorldcom committed Nov 26, 2022
2 parents f4e0245 + 2be826f commit f91f0aa
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/') && matrix.build_configuration == 'Release'
with:
body: ${{ github.event.commits[0].message }}
files: ${{ matrix.build_configuration }}\${{ matrix.build_platform }}\GitSCM-v${{ github.ref_name }}-${{ matrix.build_platform }}.zip
files: ${{ matrix.build_configuration }}/${{ matrix.build_platform }}/GitSCM-v${{ github.ref_name }}-${{ matrix.build_platform }}.zip

- name: SHA256
if: startsWith(github.ref, 'refs/tags/') && matrix.build_configuration == 'Release'
Expand Down
8 changes: 4 additions & 4 deletions DockingFeature/GitPanelDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,16 +853,16 @@ INT_PTR CALLBACK DemoDlg::run_dlgProc( UINT message, WPARAM wParam, LPARAM lPara
getClientRect( rc );

::SetWindowPos( GetDlgItem( _hSelf, IDC_EDT_BRANCH ), NULL,
rc.left + 15, rc.top + 120, rc.right - 90, 20,
rc.left + 5, rc.top + 120, rc.right - 75, 20,
SWP_NOZORDER | SWP_SHOWWINDOW );
::SetWindowPos( GetDlgItem( _hSelf, IDB_BTN_BRANCH ), NULL,
rc.right - 70, rc.top + 120, 60, 20,
rc.right - 65, rc.top + 120, 60, 20,
SWP_NOZORDER | SWP_SHOWWINDOW );
::SetWindowPos( GetDlgItem( _hSelf, IDC_EDT_DIR ), NULL,
rc.left + 15, rc.top + 150, rc.right - 25, 20,
rc.left + 5, rc.top + 150, rc.right - 10, 20,
SWP_NOZORDER | SWP_SHOWWINDOW );
::SetWindowPos( GetDlgItem( _hSelf, IDC_LSV1 ), NULL,
rc.left + 15, rc.top + 180, rc.right - 25, rc.bottom - 190,
rc.left + 5, rc.top + 180, rc.right - 10, rc.bottom - 185,
SWP_NOZORDER | SWP_SHOWWINDOW );

SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_SETCOLUMNWIDTH, COL_FILE, LVSCW_AUTOSIZE_USEHEADER );
Expand Down
14 changes: 7 additions & 7 deletions DockingFeature/gitPanel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ FONT 8,"MS Shell Dlg",0,0,0
STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_SHELLFONT
EXSTYLE WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW
BEGIN
CONTROL "",IDC_EDT_BRANCH,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,10,180,130,15,WS_EX_CLIENTEDGE
CONTROL "",IDC_EDT_BRANCH,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,2,180,135,15,WS_EX_CLIENTEDGE
CONTROL "Branch",IDB_BTN_BRANCH,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,140,180,40,15
CONTROL "",IDC_EDT_DIR,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,10,200,170,15,WS_EX_CLIENTEDGE
CONTROL "",IDC_LSV1,"SysListView32",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|LVS_SHOWSELALWAYS|LVS_REPORT,10,220,170,100,WS_EX_CLIENTEDGE
CONTROL "",IDC_EDT_DIR,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,2,200,185,15,WS_EX_CLIENTEDGE
CONTROL "",IDC_LSV1,"SysListView32",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|LVS_SHOWSELALWAYS|LVS_REPORT,2,220,185,100,WS_EX_CLIENTEDGE
CONTROL "Use TortoiseGit",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_GROUP,24,43,55,9
CONTROL "",IDC_CHK_TORTOISE,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,10,43,10,9
CONTROL "Use N++ Colors",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_GROUP,104,43,55,9
Expand All @@ -25,14 +25,14 @@ CAPTION "Git SCM Settings"
FONT 8,"MS Shell Dlg",0,0,0
STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_SHELLFONT
BEGIN
CONTROL "OK",IDB_OK,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,120,126,50,14
CONTROL "&OK",IDB_OK,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,120,126,50,14
CONTROL "Git Directory Path",IDC_GRP1,"Button",WS_CHILDWINDOW|WS_VISIBLE|BS_GROUPBOX,9,15,270,63
CONTROL "Git directory path is only needed if `git` cannot be found in your %PATH% environment variable.",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,18,27,204,18
CONTROL "git ...",IDC_BTN_GITPATH,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,15,54,40,14
CONTROL "&git ...",IDC_BTN_GITPATH,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,15,54,40,14
CONTROL "",IDC_EDT_GITPATH,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,70,54,200,15,WS_EX_CLIENTEDGE
CONTROL "Git Prompt EXE",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,9,90,55,9
CONTROL "Git &Prompt EXE",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,9,90,55,9
CONTROL "",IDC_EDT_GITPROMPT,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,70,87,200,15,WS_EX_CLIENTEDGE
CONTROL "Refresh Git Panel on Scintilla focus",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,85,110,120,9
CONTROL "&Refresh Git Panel on Scintilla focus",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,85,110,120,9
CONTROL "",IDC_CHK_SCNFOCUS,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,70,111,10,9
CONTROL "Version",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_DISABLED|WS_GROUP,10,126,30,11
CONTROL "<a></a>",IDC_STC_VER,"SysLink",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|LWS_TRANSPARENT,40,126,40,11
Expand Down
68 changes: 49 additions & 19 deletions PluginDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ void commandMenuInit()
setCommand( 1, TEXT( "GiT&k" ), giTk, NULL, false );
setCommand( 2, TEXT( "Git Pro&mpt" ), gitPrompt, NULL, false );
setCommand( 3, TEXT( "-SEPARATOR-" ), NULL, NULL, false );
setCommand( DOCKABLE_INDEX, TEXT( "Git Docking Panel" ), DockableDlg, NULL,
false );
setCommand( DOCKABLE_INDEX, TEXT( "Git Docking Panel" ), DockableDlg, NULL, _gitPanel.isVisible() ? true : false );
setCommand( 5, TEXT( "-SEPARATOR-" ), NULL, NULL, false );
setCommand( 6, TEXT( "&Add File" ), addFile, NULL, false );
setCommand( 7, TEXT( "&Unstage File" ), unstageFile, NULL, false );
Expand All @@ -179,8 +178,7 @@ void commandMenuInit()
setCommand( 16, TEXT( "&Commit" ), commitAll, NULL, false );
setCommand( 17, TEXT( "Pus&h" ), pushFile, NULL, false );
setCommand( 18, TEXT( "-SEPARATOR-" ), NULL, NULL, false );
setCommand( TORTOISE_INDEX, TEXT( "Use &TortoiseGit" ), doTortoise, NULL,
g_useTortoise ? true : false );
setCommand( TORTOISE_INDEX, TEXT( "Use &TortoiseGit" ), doTortoise, NULL, g_useTortoise ? true : false );
setCommand( 20, TEXT( "S&ettings" ), doSettings, NULL, false );
}

Expand Down Expand Up @@ -250,7 +248,7 @@ std::wstring getCurrentFileDirectory()
::SendMessage(nppData._nppHandle, NPPM_GETCURRENTDIRECTORY, MAX_PATH,
(LPARAM)path);

return std::wstring(path);
return std::wstring( path );
}

std::wstring GetLastErrorString(DWORD errorCode)
Expand Down Expand Up @@ -327,7 +325,7 @@ std::wstring getGitLocation()
///
/// @return Whether or not Git could be launched.
///
bool launchGit( std::wstring &command )
int launchGit( std::wstring &command, bool b_notGui = true )
{
STARTUPINFOW si;
PROCESS_INFORMATION pi;
Expand All @@ -337,17 +335,39 @@ bool launchGit( std::wstring &command )

if ( g_Debug )
OutputDebugString( command.c_str() );
return CreateProcess(
NULL,
const_cast<LPWSTR>( command.c_str() ),
NULL,
NULL,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
NULL,
const_cast<LPCWSTR>( getCurrentFileDirectory().c_str() ),
&si,
&pi ) != 0;

int ret = 0;
std::wstring path = getCurrentFileDirectory().c_str();
if ( path.length() > 0 || b_notGui )
ret = CreateProcess(
NULL,
const_cast<LPWSTR>( command.c_str() ),
NULL,
NULL,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
NULL,
const_cast<LPCWSTR>( getCurrentFileDirectory().c_str() ),
&si,
&pi
);
else
ret = CreateProcess(
NULL,
const_cast<LPWSTR>( command.c_str() ),
NULL,
NULL,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
NULL,
NULL,
&si,
&pi
);

if ( (ret == 0) && (path.length() == 0) )
ret = -1;
return ret;
}

///
Expand Down Expand Up @@ -388,10 +408,17 @@ void ExecGitCommand(

command += TEXT( "\"" );

if ( !launchGit( command ) )
bool b_notGui = true;
if ( ignoreFiles && !pause )
b_notGui = false;

int ret = launchGit( command, b_notGui );
if ( ret <= 0 )
{
std::wstring err = TEXT( "Could not launch Git.\n\n" );
err += GetLastErrorString(GetLastError());
if ( ret == -1 )
err += TEXT( "\nCurrent directory is empty.\n Is this a \"new-1\" file or have you saved it?\n Is the file in a current git repo directory?" );
MessageBox( nppData._nppHandle, err.c_str(),
TEXT( "Failed" ), ( MB_OK | MB_ICONWARNING | MB_APPLMODAL ) );
}
Expand Down Expand Up @@ -435,10 +462,13 @@ void ExecTortoiseCommand(
else
command += TEXT( "\" /closeonend:2" );

if ( !launchGit( command ) )
int ret = launchGit( command );
if ( ret <= 0 )
{
std::wstring err = TEXT( "Could not launch TortoiseGit.\n\n" );
err += GetLastErrorString(GetLastError());
if ( ret == -1 )
err += TEXT( "\nCurrent directory is empty.\n Is this a \"new-1\" file or have you saved it?\n Is the file in a current git repo directory?" );
MessageBox( nppData._nppHandle, err.c_str(),
TEXT( "Failed" ), ( MB_OK | MB_ICONWARNING | MB_APPLMODAL ) );
}
Expand Down
2 changes: 1 addition & 1 deletion resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define VER_MAJOR 1
#define VER_MINOR 4
#define VER_RELEASE 8
#define VER_BUILD 1
#define VER_BUILD 2
#define VER_STRING STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_RELEASE) "." STR(VER_BUILD)

#define FILE_DESCRIPTION "Notepad++ Plugin for Git SCM."
Expand Down

0 comments on commit f91f0aa

Please sign in to comment.