-
Notifications
You must be signed in to change notification settings - Fork 297
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
Programming exercises
: Remember scrolling position when switching between files in the online editor
#10053
base: develop
Are you sure you want to change the base?
Programming exercises
: Remember scrolling position when switching between files in the online editor
#10053
Conversation
…-code-editor/remember-scroll-position
…-code-editor/remember-scroll-position
…-code-editor/remember-scroll-position
Programming exercises
: Remember scroll position when switching between filesProgramming exercises
: Remember scroll position when switching between files in the online editor
Programming exercises
: Remember scroll position when switching between files in the online editorProgramming exercises
: Remember scrolling position when switching between files in the online editor
WalkthroughThe pull request addresses the issue of maintaining scroll positions when switching between files in the Monaco code editor. The changes involve updating the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts (1)
220-224
: Consider simplifying the scroll position access.The null coalescing operator is unnecessary since the
scrollTop
property is guaranteed to exist in theFileSession
type.- this.editor().setScrollTop(this.fileSession()[this.selectedFile()!].scrollTop ?? 0); + this.editor().setScrollTop(this.fileSession()[selectedFileName].scrollTop);Also, consider using the
selectedFileName
parameter instead ofthis.selectedFile()!
for consistency and to avoid the non-null assertion.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts
(4 hunks)src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts
(1 hunks)src/test/javascript/spec/component/code-editor/code-editor-monaco.component.spec.ts
(13 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts (1)
src/test/javascript/spec/component/code-editor/code-editor-monaco.component.spec.ts (1)
Pattern src/test/javascript/spec/**/*.ts
: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}
src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts (1)
🔇 Additional comments (7)
src/test/javascript/spec/component/code-editor/code-editor-monaco.component.spec.ts (1)
485-497
: LGTM! Comprehensive test coverage for scroll position functionality.
The new test case effectively verifies that the scroll position is preserved when switching between files. The test setup is clear and the assertions are precise.
src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts (1)
192-198
: LGTM: Clean implementation of scroll position management.
The new methods provide a clean interface for managing scroll positions in the Monaco editor, properly exposing the underlying Monaco editor's scroll functionality.
src/main/webapp/app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component.ts (5)
45-45
: LGTM: Well-structured type definition.
The FileSession
type has been properly extended to include the scrollTop
property for tracking scroll positions.
160-164
: LGTM: Proper scroll position preservation.
The implementation correctly saves the scroll position before switching files, with appropriate null checks for safety.
204-207
: LGTM: Clean initialization of new file sessions.
New file sessions are properly initialized with default values, including a scroll position of 0.
229-234
: LGTM: Proper scroll position preservation during content updates.
The implementation correctly preserves the scroll position when updating file content.
425-425
: LGTM: Proper initialization of new files.
New files are correctly initialized with default values, including a scroll position of 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good.
Also tested for the manual assessment scenario with many inline feedbacks for the files. They were always rendered in the correct location and the scroll position remained correct when switching back to a file. 👍
Good job, very nice improvement!
…mber-scroll-position
…mber-scroll-position
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS3, everything works as described.
…mber-scroll-position
…mber-scroll-position
…mber-scroll-position
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS1. Everything works as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS1. Works as described, scroll positions are maintained in both scenarios
…mber-scroll-position
…mber-scroll-position
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS1, everything works as expected in code and assessment editor
Checklist
General
Client
Motivation and Context
Closes #8402.
Description
The
scrollTop
attribute is added to the editor file session. It stores the absolute distance from the top of the viewport to the beginning of the file. This makes it possible to restore the scroll positions of files that have been previously looked at in a straightforward way.Steps for Testing
Prerequisites:
-> Try different files and different scrolling positions
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Code Review
Manual Tests
Test Coverage
Client
Summary by CodeRabbit
New Features
Bug Fixes
Tests