Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ function sequentialNumberGenerate() {
}
}

let result = start;
let isHex = start.startsWith('0x');
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks for a lowercase '0x' prefix; consider normalizing the input (e.g., start.toLowerCase().startsWith('0x')) to also support uppercase '0X'.

Suggested change
let isHex = start.startsWith('0x');
let isHex = start.toLowerCase().startsWith('0x');

Copilot uses AI. Check for mistakes.
let result = isHex ? parseInt(start, 16) : parseInt(start);
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using parseInt without an explicit radix on the decimal branch; specify parseInt(start, 10) to ensure consistent parsing.

Suggested change
let result = isHex ? parseInt(start, 16) : parseInt(start);
let result = isHex ? parseInt(start, 16) : parseInt(start, 10);

Copilot uses AI. Check for mistakes.

vscode.window.activeTextEditor.edit((editBuilder) => {
vscode.window.activeTextEditor.selections.forEach((element, index) => {
if (index != 0) {
result = eval(parseInt(result) + operator + parseInt(step));
result = eval(result + operator + parseInt(step));
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using eval for arithmetic operations can introduce security risks and performance overhead. Consider replacing it with direct arithmetic based on operator (e.g., a switch statement).

Suggested change
result = eval(result + operator + parseInt(step));
switch (operator) {
case '+':
result += parseInt(step);
break;
case '-':
result -= parseInt(step);
break;
case '*':
result *= parseInt(step);
break;
case '/':
result /= parseInt(step);
break;
default:
throw new Error('Unsupported operator: ' + operator);
}

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also specify a radix when calling parseInt(step) (e.g., parseInt(step, 10)) to prevent unintended parsing behavior.

Suggested change
result = eval(result + operator + parseInt(step));
result = eval(result + operator + parseInt(step, 10));

Copilot uses AI. Check for mistakes.
}

editBuilder.replace(element, result.toString());
let output = isHex ? '0x' + result.toString(16) : result.toString();
editBuilder.replace(element, output);
});
});
}
Expand Down