mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Don't crash when refreshing IntelliSense cache disconnected (#260)
* Prevent null ref exception in refresh cache handler * Send refresh complete event when disconnected * Wrap handler in global try/catch
This commit is contained in:
committed by
Kevin Cunnane
parent
dd9f2d55d4
commit
213de5cc12
@@ -456,13 +456,15 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
/// Handle the rebuild IntelliSense cache notification
|
/// Handle the rebuild IntelliSense cache notification
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task HandleRebuildIntelliSenseNotification(
|
public async Task HandleRebuildIntelliSenseNotification(
|
||||||
RebuildIntelliSenseParams configChangeParams,
|
RebuildIntelliSenseParams rebuildParams,
|
||||||
EventContext eventContext)
|
EventContext eventContext)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Logger.Write(LogLevel.Verbose, "HandleRebuildIntelliSenseNotification");
|
Logger.Write(LogLevel.Verbose, "HandleRebuildIntelliSenseNotification");
|
||||||
|
|
||||||
// Skip closing this file if the file doesn't exist
|
// Skip closing this file if the file doesn't exist
|
||||||
var scriptFile = this.CurrentWorkspace.GetFile(configChangeParams.OwnerUri);
|
var scriptFile = this.CurrentWorkspace.GetFile(rebuildParams.OwnerUri);
|
||||||
if (scriptFile == null)
|
if (scriptFile == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -473,6 +475,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
scriptFile.ClientFilePath,
|
scriptFile.ClientFilePath,
|
||||||
out connInfo);
|
out connInfo);
|
||||||
|
|
||||||
|
// check that there is an active connection for the current editor
|
||||||
|
if (connInfo != null)
|
||||||
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
ScriptParseInfo scriptInfo = GetScriptParseInfo(connInfo.OwnerUri, createIfNotExists: false);
|
ScriptParseInfo scriptInfo = GetScriptParseInfo(connInfo.OwnerUri, createIfNotExists: false);
|
||||||
@@ -507,6 +512,18 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
ServiceHost.Instance.SendEvent(IntelliSenseReadyNotification.Type, new IntelliSenseReadyParams() {OwnerUri = connInfo.OwnerUri});
|
ServiceHost.Instance.SendEvent(IntelliSenseReadyNotification.Type, new IntelliSenseReadyParams() {OwnerUri = connInfo.OwnerUri});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Send a notification to signal that autocomplete is ready
|
||||||
|
await ServiceHost.Instance.SendEvent(IntelliSenseReadyNotification.Type, new IntelliSenseReadyParams() {OwnerUri = rebuildParams.OwnerUri});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Write(LogLevel.Error, "Unknown error " + ex.ToString());
|
||||||
|
await ServiceHost.Instance.SendEvent(IntelliSenseReadyNotification.Type, new IntelliSenseReadyParams() {OwnerUri = rebuildParams.OwnerUri});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle the file configuration change notification
|
/// Handle the file configuration change notification
|
||||||
|
|||||||
Reference in New Issue
Block a user