Skip to content

Commit 0235b56

Browse files
authored
Merge pull request #1660 from paulvanbrenk/fixPathException
Don't crash when a path has invalid characters
2 parents 8d68cf8 + 202b05c commit 0235b56

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Nodejs/Product/Nodejs/SharedProject/ProjectNode.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
1+
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

33
using System;
44
using System.CodeDom.Compiler;
@@ -6511,15 +6511,24 @@ public virtual int ParseCanonicalName(string name, out uint itemId)
65116511
// we always start at the current node and go it's children down, so
65126512
// if you want to scan the whole tree, better call
65136513
// the root
6514-
name = EnsureRootedPath(name);
6515-
itemId = 0;
6516-
var child = FindNodeByFullPath(name);
6517-
if (child != null)
6514+
try
65186515
{
6519-
itemId = child.HierarchyId;
6520-
return VSConstants.S_OK;
6516+
name = EnsureRootedPath(name);
6517+
var child = FindNodeByFullPath(name);
6518+
if (child != null)
6519+
{
6520+
itemId = child.HierarchyId;
6521+
return VSConstants.S_OK;
6522+
}
6523+
}
6524+
catch (ArgumentException)
6525+
{
6526+
// This is expected when the path contains
6527+
// invalid characters. This can happen with
6528+
// 'core' node files like console, debug, etc.
65216529
}
65226530

6531+
itemId = 0;
65236532
return VSConstants.E_FAIL;
65246533
}
65256534

0 commit comments

Comments
 (0)