mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
added task to clear diagnostics when file closed (#1050)
* added task to clear diagnostics when file closed * remove unnecessary return statement
This commit is contained in:
@@ -288,6 +288,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
// Register the file open update handler
|
// Register the file open update handler
|
||||||
WorkspaceServiceInstance.RegisterTextDocOpenCallback(HandleDidOpenTextDocumentNotification);
|
WorkspaceServiceInstance.RegisterTextDocOpenCallback(HandleDidOpenTextDocumentNotification);
|
||||||
|
|
||||||
|
// Register the file open update handler
|
||||||
|
WorkspaceServiceInstance.RegisterTextDocCloseCallback(HandleDidCloseTextDocumentNotification);
|
||||||
|
|
||||||
// Register a callback for when a connection is created
|
// Register a callback for when a connection is created
|
||||||
ConnectionServiceInstance.RegisterOnConnectionTask(UpdateLanguageServiceOnConnection);
|
ConnectionServiceInstance.RegisterOnConnectionTask(UpdateLanguageServiceOnConnection);
|
||||||
|
|
||||||
@@ -701,6 +704,34 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle the file close notification
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri"></param>
|
||||||
|
/// <param name="scriptFile"></param>
|
||||||
|
/// <param name="eventContext"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task HandleDidCloseTextDocumentNotification(
|
||||||
|
string uri,
|
||||||
|
ScriptFile scriptFile,
|
||||||
|
EventContext eventContext)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// if not in the preview window and diagnostics are enabled then clear diagnostics
|
||||||
|
if (!IsPreviewWindow(scriptFile)
|
||||||
|
&& CurrentWorkspaceSettings.IsDiagnosticsEnabled)
|
||||||
|
{
|
||||||
|
await DiagnosticsHelper.ClearScriptDiagnostics(uri, eventContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Write(TraceEventType.Error, "Unknown error " + ex.ToString());
|
||||||
|
// TODO: need mechanism return errors from event handlers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle the rebuild IntelliSense cache notification
|
/// Handle the rebuild IntelliSense cache notification
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user