mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Fix validatePosition related bug
(https://github.com/Microsoft/vscode/issues/5704).
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user