Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue/4599-add cursor position information down inside the editor area. #4652

Closed
wants to merge 1 commit into from

Conversation

STF-Zero
Copy link

End-user friendly description of the problem this fixes or functionality that this introduces

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

Give a summary of what the PR does, explaining any non-trivial design decisions

This PR add information of where the cursor is inside the editor area. The information goes like:

Row: 4, Column: 15

Here's the implementation:
image

I've made this change by only modifying

frontend/src/routes/_oh.app._index/code-editor-component.tsx

  1. State management: Use React's useState hook to create a state called cursorPosition that stores the position of the cursor (row and column numbers).
  2. Register events for cursor position changes: In the handleEditorDidMount callback, use Monaco Editor's onDidChangeCursorPosition event to monitor cursor position changes. When the cursor position changes, this code updates the cursorPosition state, storing the row and column numbers of the current cursor.
    image
  3. Cursor Position Display: In the component's JSX return, the cursorPosition state is used to dynamically display the current cursor position.
    image

Link of any specific issues this addresses
source issue issue#4599

@STF-Zero STF-Zero changed the title Update code-editor-component.tsx issue/4599-add cursor position information down inside the editor area. Oct 31, 2024
@STF-Zero
Copy link
Author

STF-Zero commented Oct 31, 2024

@rbren I made a mistake to commit my local built version to the previous branch and the automatical tests didn't make it pass, so I've made a new PR here the same as the previous one.
The only difference is that I change the code to adapt to the prettier code style.
image

@enyst
Copy link
Collaborator

enyst commented Oct 31, 2024

You don't need a new PR for that, if I understand you correctly. When the tests pass after your fixes, we can merge it. Up to you which one you want! Please feel free to close the one you don't want 😀

@STF-Zero STF-Zero marked this pull request as draft October 31, 2024 06:27
@STF-Zero STF-Zero closed this Oct 31, 2024
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