未验证 提交 916e4925 编写于 作者: D David 提交者: GitHub

Merge pull request #39448 from daytonellwanger/dev/dayton/NoRoot

Live Share - Support Empty Workspace
......@@ -96,11 +96,14 @@ public async Task SetSession(CollaborationSession session)
{
_session = session;
var roots = await session.ListRootsAsync(CancellationToken.None).ConfigureAwait(false);
_remoteRootPath = session.ConvertSharedUriToLocalPath(roots[0]);
_remoteRootPath = _remoteRootPath.Substring(0, _remoteRootPath.Length - 1);
var lastSlash = _remoteRootPath.LastIndexOf('\\');
_externalPath = _remoteRootPath.Substring(0, lastSlash + 1);
_externalPath += "~external";
if (roots.Length > 0)
{
_remoteRootPath = session.ConvertSharedUriToLocalPath(roots[0]);
_remoteRootPath = _remoteRootPath.Substring(0, _remoteRootPath.Length - 1);
var lastSlash = _remoteRootPath.LastIndexOf('\\');
_externalPath = _remoteRootPath.Substring(0, lastSlash + 1);
_externalPath += "~external";
}
IsRemoteSession = true;
session.RemoteServicesChanged += (object sender, RemoteServicesChangedEventArgs e) =>
{
......@@ -175,8 +178,9 @@ public void NotifyOnDocumentOpened(string moniker, ITextBuffer textBuffer, IVsHi
private bool IsExternalLocalUri(string localPath)
{
return localPath.StartsWith(_externalPath) &&
localPath.Length > (_externalPath.Length + 1);
return _externalPath == null
? false
: localPath.StartsWith(_externalPath) && localPath.Length > (_externalPath.Length + 1);
}
public Document GetOrAddDocument(string filePath)
......@@ -192,10 +196,15 @@ public Document GetOrAddDocument(string filePath)
return null;
}
if (_remoteRootPath == null)
{
return null;
}
// If the document is within the joined folder or it's a registered external file,
// add it to the workspace, otherwise bail out.
if (!filePath.StartsWith(_remoteRootPath) &&
!IsExternalLocalUri(filePath))
!IsExternalLocalUri(filePath))
{
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册