提交 5ed6d33d 编写于 作者: A Alex Dima

Fix snippet controller & tests

上级 f4bc1c09
......@@ -141,6 +141,8 @@ export class InsertSnippetController {
// };
// print();
let _highlightRange = this.model.getDecorationRange(this.highlightDecorationId);
this.listenersToRemove = [];
this.listenersToRemove.push(this.editor.onDidChangeModelContent((e) => {
// console.log('-------MODEL CHANGED');
......@@ -162,17 +164,18 @@ export class InsertSnippetController {
return;
}
const highlightRange = this.model.getDecorationRange(this.highlightDecorationId);
for (let i = 0, len = e.changes.length; i < len; i++) {
const change = e.changes[i];
const intersection = highlightRange.intersectRanges(change.range);
const intersection = _highlightRange.intersectRanges(change.range);
if (intersection === null) {
// Did an edit outside of the snippet
this.stopAll();
return;
}
}
// Keep the highlightRange for the next round of model change events
_highlightRange = this.model.getDecorationRange(this.highlightDecorationId);
}));
this.listenersToRemove.push(this.editor.onDidChangeCursorPosition((e: editorCommon.ICursorPositionChangedEvent) => {
......@@ -180,6 +183,10 @@ export class InsertSnippetController {
return;
}
var highlightRange = this.model.getDecorationRange(this.highlightDecorationId);
if (!highlightRange) {
this.stopAll();
return;
}
var lineNumber = e.position.lineNumber;
if (lineNumber < highlightRange.startLineNumber || lineNumber > highlightRange.endLineNumber) {
this.stopAll();
......
......@@ -129,7 +129,7 @@ suite('SnippetController', () => {
forceMoveMarkers: false,
identifier: null,
isAutoWhitespaceEdit: false,
range: new Range(7, 100, 8, 100),
range: new Range(8, 1, 8, 100),
text: null
}]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册