mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-20 01:25:41 -05:00
Handle open\close document events with git URI prefix (#254)
This commit is contained in:
@@ -48,6 +48,23 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given URI is contained in a workspace
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns>Flag indicating if the file is tracked in workspace</returns>
|
||||
public bool ContainsFile(string filePath)
|
||||
{
|
||||
Validate.IsNotNullOrWhitespaceString("filePath", filePath);
|
||||
|
||||
// Resolve the full file path
|
||||
string resolvedFilePath = this.ResolveFilePath(filePath);
|
||||
string keyName = resolvedFilePath.ToLower();
|
||||
|
||||
ScriptFile scriptFile = null;
|
||||
return this.workspaceFiles.TryGetValue(keyName, out scriptFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an open file in the workspace. If the file isn't open but
|
||||
/// exists on the filesystem, load and return it. Virtual method to
|
||||
@@ -124,9 +141,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
// with 'inmemory'. Untitled files which have been marked of
|
||||
// type SqlTools have a path starting with 'untitled'.
|
||||
return
|
||||
filePath.StartsWith("inmemory") ||
|
||||
filePath.StartsWith("tsqloutput") ||
|
||||
filePath.StartsWith("untitled");
|
||||
filePath.StartsWith("inmemory:") ||
|
||||
filePath.StartsWith("tsqloutput:") ||
|
||||
filePath.StartsWith("git:") ||
|
||||
filePath.StartsWith("untitled:");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -244,6 +244,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
{
|
||||
Logger.Write(LogLevel.Verbose, "HandleDidOpenTextDocumentNotification");
|
||||
|
||||
if (IsScmEvent(openParams.TextDocument.Uri))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// read the SQL file contents into the ScriptFile
|
||||
ScriptFile openedFile = Workspace.GetFileBuffer(openParams.TextDocument.Uri, openParams.TextDocument.Text);
|
||||
|
||||
@@ -260,6 +265,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
{
|
||||
Logger.Write(LogLevel.Verbose, "HandleDidCloseTextDocumentNotification");
|
||||
|
||||
if (IsScmEvent(closeParams.TextDocument.Uri))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip closing this file if the file doesn't exist
|
||||
var closedFile = Workspace.GetFile(closeParams.TextDocument.Uri);
|
||||
if (closedFile == null)
|
||||
@@ -311,6 +321,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
EndOffset = changeRange.End.Character + 1
|
||||
};
|
||||
}
|
||||
|
||||
internal static bool IsScmEvent(string filePath)
|
||||
{
|
||||
// if the URI is prefixed with git: then we want to skip processing that file
|
||||
return filePath.StartsWith("git:");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user