提交 04f89500 编写于 作者: J Johannes Rieken

fix validatePosition, fixes #15882

上级 023cc2b1
......@@ -212,19 +212,19 @@ class MirrorModel extends MirrorModel2 implements ICommonModel {
lineNumber = 1;
column = 1;
hasChanged = true;
}
else if (lineNumber >= this._lines.length) {
} else if (lineNumber > this._lines.length) {
lineNumber = this._lines.length;
column = this._lines[lineNumber - 1].length + 1;
hasChanged = true;
}
else {
} else {
let maxCharacter = this._lines[lineNumber - 1].length + 1;
if (column < 1) {
column = 1;
hasChanged = true;
}
else if (column >= maxCharacter) {
else if (column > maxCharacter) {
column = maxCharacter;
hasChanged = true;
}
......
......@@ -87,6 +87,11 @@ suite('EditorSimpleWorker', () => {
assertPositionAt(Number.MAX_VALUE, 4, 30);
});
test('ICommonModel#validatePosition, issue #15882', function () {
let model = worker.addModel(['{"id": "0001","type": "donut","name": "Cake","image":{"url": "images/0001.jpg","width": 200,"height": 200},"thumbnail":{"url": "images/thumbnails/0001.jpg","width": 32,"height": 32}}']);
assert.equal(model.offsetAt({ lineNumber: 1, column: 2 }), 1);
});
test('MoreMinimal', function () {
return worker.computeMoreMinimalEdits(model.uri.toString(), [{ text: 'This is line One', range: new Range(1, 1, 1, 17) }], []).then(edits => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册