mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Change to scope file tree to the known path if root folders dont return correctly (#816)
* Change to scope file tree to the known path if root folders dont return correctly. * Fixing a typo (duplicate assignment)
This commit is contained in:
@@ -160,9 +160,21 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
|
||||
{
|
||||
this.fileTree.SelectedNode = lastNode;
|
||||
}
|
||||
|
||||
// If root folders returned from sys.dm_os_enumerate_filesystem don't match the folders present, expandPath might not be found
|
||||
// Bug: https://github.com/microsoft/azuredatastudio/issues/4767
|
||||
// Workaround : scope file browser tree to expandPath explicitly
|
||||
try
|
||||
{
|
||||
this.ScopeFileTreeToPath(expandPath);
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new FileBrowserException(string.Format(SR.InvalidPathError, this.expandPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastNode != null)
|
||||
{
|
||||
@@ -248,6 +260,26 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates file tree for a scoped path
|
||||
/// Removes the top level file tree so only use this if you intend to do that
|
||||
/// </summary>
|
||||
/// <param name="expandPath">path to consider at top level node for tree</param>
|
||||
private void ScopeFileTreeToPath(string expandPath)
|
||||
{
|
||||
this.fileTree = new FileTree();
|
||||
FileTreeNode node = new FileTreeNode()
|
||||
{
|
||||
Name = expandPath,
|
||||
FullPath = expandPath,
|
||||
IsExpanded = true
|
||||
};
|
||||
|
||||
this.fileTree.RootNode.AddChildNode(node);
|
||||
node.Children = this.GetChildren(node.FullPath);
|
||||
this.fileTree.SelectedNode = node;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares a file name to the user specified mask using a regular expression
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user