Skip to content

Commit

Permalink
avoid shadowed variables
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Sep 4, 2019
1 parent 4e230fd commit 491daf2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/vs/base/common/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,17 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON

function scanHexDigits(count: number): number {
let digits = 0;
let value = 0;
let hexValue = 0;
while (digits < count) {
const ch = text.charCodeAt(pos);
if (ch >= CharacterCodes._0 && ch <= CharacterCodes._9) {
value = value * 16 + ch - CharacterCodes._0;
hexValue = hexValue * 16 + ch - CharacterCodes._0;
}
else if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) {
value = value * 16 + ch - CharacterCodes.A + 10;
hexValue = hexValue * 16 + ch - CharacterCodes.A + 10;
}
else if (ch >= CharacterCodes.a && ch <= CharacterCodes.f) {
value = value * 16 + ch - CharacterCodes.a + 10;
hexValue = hexValue * 16 + ch - CharacterCodes.a + 10;
}
else {
break;
Expand All @@ -226,9 +226,9 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON
digits++;
}
if (digits < count) {
value = -1;
hexValue = -1;
}
return value;
return hexValue;
}

function setPosition(newPosition: number) {
Expand Down
12 changes: 6 additions & 6 deletions src/vs/base/common/jsonEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ function withFormatting(text: string, edit: Edit, formattingOptions: FormattingO

// apply the formatting edits and track the begin and end offsets of the changes
for (let i = edits.length - 1; i >= 0; i--) {
const edit = edits[i];
newText = applyEdit(newText, edit);
begin = Math.min(begin, edit.offset);
end = Math.max(end, edit.offset + edit.length);
end += edit.content.length - edit.length;
const curr = edits[i];
newText = applyEdit(newText, curr);
begin = Math.min(begin, curr.offset);
end = Math.max(end, curr.offset + curr.length);
end += curr.content.length - curr.length;
}
// create a single edit with all changes
const editLength = text.length - (newText.length - end) - begin;
Expand Down Expand Up @@ -182,4 +182,4 @@ export function applyEdits(text: string, edits: Edit[]): string {

export function isWS(text: string, offset: number) {
return '\r\n \t'.indexOf(text.charAt(offset)) !== -1;
}
}

0 comments on commit 491daf2

Please sign in to comment.