Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
set original(newValue: Completer.ITextState | null) {
let unchanged =
this._original === newValue ||
(this._original &&
newValue &&
JSONExt.deepEqual(newValue, this._original));
if (unchanged) {
return;
}
this._reset();
// Set both the current and original to the same value when original is set.
this._current = this._original = newValue;
this._stateChanged.emit(undefined);
}
set current(newValue: Completer.ITextState | null) {
const unchanged =
this._current === newValue ||
(this._current && newValue && JSONExt.deepEqual(newValue, this._current));
if (unchanged) {
return;
}
const original = this._original;
// Original request must always be set before a text change. If it isn't
// the model fails silently.
if (!original) {
return;
}
const cursor = this._cursor;
// Cursor must always be set before a text change. This happens
it('should return the typeMap', () => {
let model = new CompleterModel();
let options = ['foo'];
let typeMap = { foo: 'instance' };
model.setOptions(options, typeMap);
expect(JSONExt.deepEqual(model.typeMap(), typeMap)).to.be.ok;
});
});
set(value: JSONValue): void {
let oldValue = this._value;
if (JSONExt.deepEqual(oldValue, value)) {
return;
}
this._value = value;
this._changed.emit({
oldValue: oldValue,
newValue: value
});
}
protected async requestSpecs(): Promise {
const specs = await restapi.getSpecs(this.serverSettings);
if (this.isDisposed) {
return;
}
if (!JSONExt.deepEqual(specs, this._specs)) {
this._specs = specs;
this._specsChanged.emit(specs);
}
}
private _triggerChange(
oldState: [string, string, string],
newState: [string, string, string]
) {
if (JSONExt.deepEqual(oldState, newState)) {
this.stateChanged.emit(void 0);
}
}
setOptions(
newValue: IterableOrArrayLike,
typeMap?: Completer.TypeMap
) {
const values = toArray(newValue || []);
const types = typeMap || {};
if (
JSONExt.deepEqual(values, this._options) &&
JSONExt.deepEqual(types, this._typeMap)
) {
return;
}
if (values.length) {
this._options = values;
this._typeMap = types;
this._orderedTypes = Private.findOrderedTypes(types);
} else {
this._options = [];
this._typeMap = {};
this._orderedTypes = [];
}
this._stateChanged.emit(undefined);
}
set state(state: SettingEditor.IPluginLayout) {
if (JSONExt.deepEqual(this.state, state)) {
return;
}
this._rawEditor.sizes = state.sizes;
this.update();
}
return ArrayExt.findLastValue(this._commands.keyBindings, kb => {
return kb.command === command && JSONExt.deepEqual(kb.args, args);
}) || null;
}