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