mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -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
|
||||
WorkspaceServiceInstance.RegisterTextDocOpenCallback(HandleDidOpenTextDocumentNotification);
|
||||
|
||||
// Register the file open update handler
|
||||
WorkspaceServiceInstance.RegisterTextDocCloseCallback(HandleDidCloseTextDocumentNotification);
|
||||
|
||||
// Register a callback for when a connection is created
|
||||
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>
|
||||
/// Handle the rebuild IntelliSense cache notification
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user