mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-22 09:35:38 -05:00
- Additional handling of document events with "perforce:" or other SCM strings - Much of the handling had been added already, but adding in additional validation and ensuring that everywhere `Workspace.GetFile` is called we add a not-null check to avoid null reference errors
This commit is contained in:
@@ -38,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
|
||||
|
||||
public override void InitializeService(IProtocolEndpoint serviceHost)
|
||||
{
|
||||
{
|
||||
Logger.Write(LogLevel.Verbose, "TSqlFormatter initialized");
|
||||
serviceHost.SetRequestHandler(DocumentFormattingRequest.Type, HandleDocFormatRequest);
|
||||
serviceHost.SetRequestHandler(DocumentRangeFormattingRequest.Type, HandleDocRangeFormatRequest);
|
||||
@@ -107,6 +107,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
{
|
||||
var range = docFormatParams.Range;
|
||||
ScriptFile scriptFile = GetFile(docFormatParams);
|
||||
if (scriptFile == null)
|
||||
{
|
||||
return new TextEdit[0];
|
||||
}
|
||||
TextEdit textEdit = new TextEdit { Range = range };
|
||||
string text = scriptFile.GetTextInRange(range.ToBufferRange());
|
||||
return DoFormat(docFormatParams, textEdit, text);
|
||||
@@ -118,7 +122,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
return await Task.Factory.StartNew(() =>
|
||||
{
|
||||
var scriptFile = GetFile(docFormatParams);
|
||||
if (scriptFile.FileLines.Count == 0)
|
||||
if (scriptFile == null
|
||||
|| scriptFile.FileLines.Count == 0)
|
||||
{
|
||||
return new TextEdit[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user