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

Programming exercises: Show whitespace changes in diff viewer #9962

Closed

Conversation

magaupp
Copy link
Contributor

@magaupp magaupp commented Dec 6, 2024

Checklist

General

Client

  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple screenshots/screencasts of my UI changes.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

Whitespace-only changes are currently hidden in the diff viewer. This, for example, hides tabs vs spaces inconsistencies and causes inconsistencies with the displayed line counts.

Description

This PR disables the ignoreTrimWhitespace option of the monaco DiffEditor.

Closes #9928.

Steps for Testing

  1. Create a programming exercise
  2. Replace all space indentation with tabs in the template repo and keep it as spaces in the solution repo
  3. Wait until the build finishes
  4. Click on "Review Changes"
  5. Verify that changes in indentation are shown
  6. Verify that the shown number of changed lines matches with the displayed changes with non-empty lines

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

  • Code Review

Manual Tests

  • Test

Test Coverage

Screenshots

Before

grafik

After

grafik

Summary by CodeRabbit

  • New Features
    • Enhanced the diff editor to include an option for ignoring whitespace during text comparisons, improving accuracy in visual diffs.

@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Dec 6, 2024
@magaupp magaupp temporarily deployed to artemis-test2.artemis.cit.tum.de December 7, 2024 15:36 — with GitHub Actions Inactive
@magaupp magaupp marked this pull request as ready for review December 7, 2024 15:54
@magaupp magaupp requested a review from a team as a code owner December 7, 2024 15:54
Copy link

coderabbitai bot commented Dec 7, 2024

Walkthrough

The pull request modifies the createStandaloneDiffEditor method of the MonacoEditorService class by adding a new property, ignoreTrimWhitespace, to the configuration object used in the monaco.editor.createDiffEditor method. This change affects how whitespace is treated during text comparisons in the diff editor, specifically ensuring that whitespace trimming does not alter the comparison results.

Changes

File Path Change Summary
src/main/webapp/app/shared/monaco-editor/... Updated createStandaloneDiffEditor method to include ignoreTrimWhitespace: false.

Assessment against linked issues

Objective Addressed Explanation
The number of added and deleted lines of code between the template and the solution submission should be correct. (#9928)

Possibly related PRs

Suggested labels

bugfix, feature, tests, ready to merge

Suggested reviewers

  • florian-glombik
  • JohannesWt
  • pzdr7
  • Jan-Thurner

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (2)
src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts (2)

Line range hint 92-95: Consider enhancing the method documentation.

The JSDoc comment should mention the whitespace handling behavior since it's a significant aspect of the diff viewer's functionality.

Consider updating the documentation like this:

 /**
  * Creates a standalone diff editor (see {@link MonacoDiffEditorComponent}) with sensible default settings and inserts it into the given DOM element.
+ * The diff editor is configured to show whitespace changes to ensure accurate comparison of indentation and spacing.
  * @param domElement The DOM element to insert the editor into.
  */

Line range hint 92-104: Consider the performance impact on large diffs.

While showing whitespace changes is valuable, it might affect the rendering performance of large diffs. The current configuration looks good, but consider monitoring the performance impact, especially in programming exercises with substantial whitespace changes.

Some suggestions:

  1. Consider adding telemetry to monitor diff rendering times
  2. If performance issues arise, we could add a toggle button to enable/disable whitespace diff visibility
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0005603 and 2846d92.

📒 Files selected for processing (1)
  • src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

🔇 Additional comments (1)
src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts (1)

103-103: LGTM! The change correctly implements whitespace diff visibility.

The addition of ignoreTrimWhitespace: false directly addresses the PR objective and will help solve the issue of incorrect diff counts in programming exercises.

Let's verify that this is the only instance where we need to configure whitespace handling:

✅ Verification successful

The search results show only two matches:

  1. The line we're reviewing in monaco-editor.service.ts
  2. A string manipulation in short-answer-question-util.service.ts which is unrelated as it's just text processing logic, not editor configuration

Let me verify if there are any other Monaco editor configurations that might be affected:


Let me check one final thing to ensure there are no other diff editor configurations:


Based on the comprehensive search results, I can now provide the final response:

✅ The whitespace configuration change is correctly isolated to the diff editor configuration

The change to ignoreTrimWhitespace: false in monaco-editor.service.ts is the only place where whitespace handling needs to be configured for the Monaco diff editor. This is verified by:

  1. The diff editor is only created in one place via createStandaloneDiffEditor
  2. No other whitespace trimming configurations exist in the codebase
  3. The configuration is properly scoped within the diff editor initialization
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other potential locations where whitespace trimming might be configured
rg -i "trimwhitespace|whitespace.*trim" --type ts

Length of output: 380


Script:

#!/bin/bash
# Search for Monaco editor configuration patterns
rg -i "monaco.*config|editor.*config" --type ts -A 5

Length of output: 2285


Script:

#!/bin/bash
# Search specifically for diff editor configurations
rg -i "diffeditor|diff.*editor" --type ts -A 3

Length of output: 25418

Copy link

@HawKhiem HawKhiem left a comment

Choose a reason for hiding this comment

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

Tested on TS2. Everything works as described

image

Copy link

@ItsaaaMeMario ItsaaaMeMario left a comment

Choose a reason for hiding this comment

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

Tested on TS3, works as intended.
Bildschirmfoto 2024-12-08 um 14 53 32

@b-fein b-fein added this to the 7.7.5 milestone Dec 8, 2024
Copy link
Member

@krusche krusche left a comment

Choose a reason for hiding this comment

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

I am typically not interested in whitespace changes as an instructor, so the setting in the client was already correct. The numbers should then also take this setting into account, regardless of whether they are calculated on the server or client.

We could offer an option similar to Github "Files changed" tab in the future in case other instructors are interested in whitespace changes.

image

@magaupp magaupp removed this from the 7.7.5 milestone Dec 8, 2024
@magaupp
Copy link
Contributor Author

magaupp commented Dec 8, 2024

We'll open another PR for a whitespace option in diffs

@magaupp magaupp closed this Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) small
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

Programming Exercise: Git diff between template and solution shows incorrect number of changes
5 participants