Fix validatePosition related bug

(https://github.com/Microsoft/vscode/issues/5704).
This commit is contained in:
aioute Gao
2016-04-24 07:55:03 +09:00
parent 3fc5204134
commit 7d870e5721
2 changed files with 28 additions and 24 deletions

View File

@@ -393,24 +393,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;
@@ -673,4 +674,4 @@ export class MainThreadDocuments {
}
}, onUnexpectedError);
}
}
}