mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Merge pull request #5705 from aioutecism/hotfix/validate-position
Fix validatePosition related bug
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user