Skip to content

output hex if user input is hex#20

Open
ryanroe wants to merge 1 commit intoNeptuneDesign:masterfrom
ryanroe:master
Open

output hex if user input is hex#20
ryanroe wants to merge 1 commit intoNeptuneDesign:masterfrom
ryanroe:master

Conversation

@ryanroe
Copy link

@ryanroe ryanroe commented Jul 17, 2025

No description provided.

Copilot AI review requested due to automatic review settings July 17, 2025 02:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds hexadecimal support for sequential number generation when the user’s input starts with a 0x prefix.

  • Detects hex input via an isHex flag
  • Parses the starting value with base 16 and formats subsequent results back to hex
  • Falls back to decimal parsing and output when no hex prefix is found
Comments suppressed due to low confidence (1)

extension.js:43

  • There are no tests covering the new hexadecimal input/output logic; consider adding unit tests to verify hex parsing and formatting behavior.
				let isHex = start.startsWith('0x');

}

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 = start;
let isHex = start.startsWith('0x');
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.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.
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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants