Skip to content

Commit 71dfa78

Browse files
authored
Merge pull request #16 from ccHanibal/master
Fix an exception when empty windows are active
2 parents 6b47c09 + 1045967 commit 71dfa78

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

TortoiseGitToolbar/Config/Constants/PathConfiguration.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,25 @@ public static string GetSolutionPath(Solution2 solution)
7474

7575
public static string GetOpenedFilePath(Solution2 solution)
7676
{
77-
return solution != null && solution.DTE != null && solution.DTE.ActiveDocument != null
77+
if (solution != null && solution.DTE != null)
78+
{
79+
try
80+
{
81+
if (solution.DTE.ActiveDocument == null) // no active window
82+
return null;
83+
}
84+
catch (ArgumentException)
85+
{
86+
// active window is no file (e.g. the project properties)
87+
return null;
88+
}
89+
7890
// GetExactPathName is needed because visual studio can provide lowercase path,
7991
// but git is case sensitive to file names
80-
? GetExactPathName(solution.DTE.ActiveDocument.FullName)
81-
: null;
92+
return GetExactPathName(solution.DTE.ActiveDocument.FullName);
93+
}
94+
95+
return null;
8296
}
8397

8498
/// <summary>

0 commit comments

Comments
 (0)