@kusto/monaco-kusto
Advanced tools
Comparing version
{ | ||
"name": "@kusto/monaco-kusto", | ||
"version": "5.3.5", | ||
"version": "5.3.6", | ||
"description": "CSL, KQL plugin for the Monaco Editor", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -18,19 +18,42 @@ import * as ls from './_deps/vscode-languageserver-types/main'; | ||
this._schemaListener = Object.create(null); | ||
this._cursorListener = Object.create(null); | ||
this._debouncedValidations = Object.create(null); | ||
var onModelAdd = function (model) { | ||
var languageId = model.getLanguageId(); | ||
var modelUri = model.uri.toString(); | ||
if (languageId !== _this._languageId) { | ||
return; | ||
} | ||
var debouncedValidation = _.debounce(function (intervals) { return _this._doValidate(model, languageId, intervals); }, 500); | ||
_this._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) { | ||
var debouncedValidation = _this.getOrCreateDebouncedValidation(model, languageId); | ||
_this._contentListener[modelUri] = model.onDidChangeContent(function (e) { | ||
var intervalsToValidate = changeEventToIntervals(e); | ||
debouncedValidation(intervalsToValidate); | ||
}); | ||
_this._configurationListener[model.uri.toString()] = _this.defaults.onDidChange(function () { | ||
_this._configurationListener[modelUri] = _this.defaults.onDidChange(function () { | ||
self.setTimeout(function () { return _this._doValidate(model, languageId, []); }, 0); | ||
}); | ||
_this._schemaListener[model.uri.toString()] = onSchemaChange(function () { | ||
_this._schemaListener[modelUri] = onSchemaChange(function () { | ||
self.setTimeout(function () { return _this._doValidate(model, languageId, []); }, 0); | ||
}); | ||
}; | ||
var onEditorAdd = function (editor) { | ||
var editorId = editor.getId(); | ||
if (!_this._cursorListener[editorId]) { | ||
editor.onDidDispose(function () { | ||
var _a; | ||
(_a = _this._cursorListener[editorId]) === null || _a === void 0 ? void 0 : _a.dispose(); | ||
delete _this._cursorListener[editorId]; | ||
}); | ||
_this._cursorListener[editorId] = editor.onDidChangeCursorSelection(function (e) { | ||
var model = editor.getModel(); | ||
var languageId = model.getLanguageId(); | ||
if (languageId !== _this._languageId) { | ||
return; | ||
} | ||
var cursorOffset = model.getOffsetAt(e.selection.getPosition()); | ||
var debouncedValidation = _this.getOrCreateDebouncedValidation(model, languageId); | ||
debouncedValidation([{ start: cursorOffset, end: cursorOffset }]); | ||
}); | ||
} | ||
}; | ||
var onModelRemoved = function (model) { | ||
@@ -54,3 +77,9 @@ _this._monacoInstance.editor.setModelMarkers(model, _this._languageId, []); | ||
} | ||
var debouncedValidation = _this._debouncedValidations[uriStr]; | ||
if (debouncedValidation) { | ||
debouncedValidation.cancel(); | ||
delete _this._debouncedValidations[uriStr]; | ||
} | ||
}; | ||
this._disposables.push(this._monacoInstance.editor.onDidCreateEditor(onEditorAdd)); | ||
this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd)); | ||
@@ -67,6 +96,21 @@ this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved)); | ||
} | ||
for (var key in _this._cursorListener) { | ||
_this._cursorListener[key].dispose(); | ||
} | ||
for (var key in _this._debouncedValidations) { | ||
_this._debouncedValidations[key].cancel(); | ||
} | ||
}, | ||
}); | ||
this._monacoInstance.editor.getModels().forEach(onModelAdd); | ||
this._monacoInstance.editor.getEditors().forEach(onEditorAdd); | ||
} | ||
DiagnosticsAdapter.prototype.getOrCreateDebouncedValidation = function (model, languageId) { | ||
var _this = this; | ||
var modelUri = model.uri.toString(); | ||
if (!this._debouncedValidations[modelUri]) { | ||
this._debouncedValidations[modelUri] = _.debounce(function (intervals) { return _this._doValidate(model, languageId, intervals); }, 500); | ||
} | ||
return this._debouncedValidations[modelUri]; | ||
}; | ||
DiagnosticsAdapter.prototype.dispose = function () { | ||
@@ -73,0 +117,0 @@ this._disposables.forEach(function (d) { return d && d.dispose(); }); |
/*!----------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* monaco-kusto version: 5.3.5(undefined) | ||
* monaco-kusto version: 5.3.6(undefined) | ||
* Released under the MIT license | ||
@@ -5,0 +5,0 @@ * https://https://github.com/Azure/monaco-kusto/blob/master/README.md |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
8994659
0.06%53398
0.17%