Merge pull request #5705 from aioutecism/hotfix/validate-position

Fix validatePosition related bug
This commit is contained in:
Alexandru Dima
2016-05-04 18:25:52 +02:00
3 changed files with 53 additions and 25 deletions

View File

@@ -395,24 +395,25 @@ export class ExtHostDocumentData extends MirrorModel2 {
if (line < 0) {
line = 0;
hasChanged = true;
}
if (line >= this._lines.length) {
line = this._lines.length - 1;
hasChanged = true;
}
if (character < 0) {
character = 0;
hasChanged = true;
}
let maxCharacter = this._lines[line].length;
if (character > maxCharacter) {
character = maxCharacter;
else if (line >= this._lines.length) {
line = this._lines.length - 1;
character = this._lines[line].length;
hasChanged = true;
}
else {
let maxCharacter = this._lines[line].length;
if (character < 0) {
character = 0;
hasChanged = true;
}
else if (character > maxCharacter) {
character = maxCharacter;
hasChanged = true;
}
}
if (!hasChanged) {
return position;
@@ -674,4 +675,4 @@ export class MainThreadDocuments {
}
}, onUnexpectedError);
}
}
}