Skip to content

Conversation

@Rahilralu
Copy link

edited the terminal movement like moving left and right in the terminal . and editing the text after movement.

Copy link
Contributor

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

This PR implements cursor movement functionality in the terminal component, allowing users to navigate left and right within their input text and edit at any position.

  • Added cursor position tracking with left/right arrow key navigation
  • Enhanced backspace functionality to work with cursor positioning
  • Implemented text insertion at cursor position for both regular characters and spaces

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

term.write(`\x1b[${charsToMoveBack}D`);
}
}
else if(domEvent.key == 'ArrowLeft'){
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Use strict equality (===) instead of loose equality (==) for comparison. This prevents type coercion issues and follows JavaScript best practices.

Suggested change
else if(domEvent.key == 'ArrowLeft'){
else if(domEvent.key === 'ArrowLeft'){

Copilot uses AI. Check for mistakes.
term.write('\x1b[D');
}
}
else if(domEvent.key == 'ArrowRight'){
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Use strict equality (===) instead of loose equality (==) for comparison. This prevents type coercion issues and follows JavaScript best practices.

Suggested change
else if(domEvent.key == 'ArrowRight'){
else if(domEvent.key === 'ArrowRight'){

Copilot uses AI. Check for mistakes.
Comment on lines +147 to 158
else if(domEvent.key == 'ArrowLeft'){
if(cursorPos > 0){
cursorPos--;
term.write('\x1b[D');
}
}
else if(domEvent.key == 'ArrowRight'){
if(cursorPos < input.length){
cursorPos++;
term.write('\x1b[C');
}
}
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Inconsistent spacing around parentheses and braces. Add spaces after 'if' and around parentheses for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.

let input = '';
let currentDir = 'home';
let cursorPos = 0;
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The cursorPos variable should be reset to 0 when input is cleared (after Enter key is pressed) to maintain proper cursor positioning for new commands.

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.

1 participant