From 215136dd73e7641414aaac2610212d4167526c1b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 31 Oct 2017 11:55:03 -0700 Subject: [PATCH] Use onDidChangeText instead of onWillChange --- dist/server/omnisharp-text-editor.js | 13 ++++++------- lib/server/omnisharp-text-editor.ts | 8 ++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/dist/server/omnisharp-text-editor.js b/dist/server/omnisharp-text-editor.js index 845d8cde..05cb6869 100644 --- a/dist/server/omnisharp-text-editor.js +++ b/dist/server/omnisharp-text-editor.js @@ -18,6 +18,8 @@ var _tsDisposables = require('ts-disposables'); var _projectViewModel = require('./project-view-model'); +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var contextItems = new Map(); @@ -60,8 +62,10 @@ var OmnisharpEditorContext = exports.OmnisharpEditorContext = function () { }); }), solution.open({ FileName: editor.getPath() }).subscribe(), solution.updatebuffer({ FileName: editor.getPath(), FromDisk: true }, { silent: true }).subscribe(), function () { solution.disposable.add(solution.close({ FileName: editor.getPath() }).subscribe()); - }, editor.getBuffer().onWillChange(function (change) { - _this.pushChange(change); + }, editor.getBuffer().onDidChangeText(function (event) { + var _changes; + + (_changes = _this._changes).push.apply(_changes, _toConsumableArray(event.changes)); }), editor.onDidStopChanging(function () { if (_this.hasChanges) { solution.updatebuffer({ FileName: editor.getPath(), Changes: _this.popChanges() }, { silent: true }); @@ -107,11 +111,6 @@ var OmnisharpEditorContext = exports.OmnisharpEditorContext = function () { } return this._items.get(name); } - }, { - key: 'pushChange', - value: function pushChange(change) { - this._changes.push(change); - } }, { key: 'popChanges', value: function popChanges() { diff --git a/lib/server/omnisharp-text-editor.ts b/lib/server/omnisharp-text-editor.ts index 055567b9..2db86c6c 100644 --- a/lib/server/omnisharp-text-editor.ts +++ b/lib/server/omnisharp-text-editor.ts @@ -60,8 +60,8 @@ export class OmnisharpEditorContext implements IDisposable { () => { solution.disposable.add(solution.close({ FileName: editor.getPath() }).subscribe()); }, - editor.getBuffer().onWillChange((change: { oldRange: TextBuffer.Range; newRange: TextBuffer.Range; oldText: string; newText: string; }) => { - this.pushChange(change); + editor.getBuffer().onDidChangeText((event: {changes: IAtomTextChange[]}) => { + this._changes.push(...event.changes) }), editor.onDidStopChanging(() => { if (this.hasChanges) { @@ -122,10 +122,6 @@ export class OmnisharpEditorContext implements IDisposable { return this._items.get(name); } - public pushChange(change: IAtomTextChange) { - this._changes.push(change); - } - public popChanges() { if (!this._changes.length) { return null;