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

fix: update markings on update of same editor value #33394

Merged
merged 1 commit into from
May 14, 2024

Conversation

ApekshaBhosale
Copy link
Contributor

@ApekshaBhosale ApekshaBhosale commented May 13, 2024

Description

on JS editor, if content has a linting warning or an error while re-pasting same value removes those linting warning and errors. We check if errors are changed but as the replacement of text was very quick, markings gets vanished as it has same errors but marking doesn't get updated

fixes - https://internal.appsmith.com/app/cypress-dashboard/run-details-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9058960988&attempt=4&selectiontype=test&testsstatus=failed&specsstatus=fail

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9064397255
Commit: 1204003
Cypress dashboard url: Click here!

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Copy link
Contributor

coderabbitai bot commented May 13, 2024

Walkthrough

Walkthrough

The recent update in the CodeEditor component enhances functionality by introducing a conditional handling for the updateLintingCallback. Additionally, it revises how annotations are utilized within the getLintAnnotations function, aiming to improve the linting process and overall code quality in the editor.

Changes

File Changes
app/.../CodeEditor/index.tsx Added handling for updateLintingCallback if present; modified usage of annotations in getLintAnnotations.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 217da70 and 1204003.
Files selected for processing (1)
  • app/client/src/components/editorComponents/CodeEditor/index.tsx (2 hunks)
Additional comments not posted (1)
app/client/src/components/editorComponents/CodeEditor/index.tsx (1)

651-654: Ensure that the updateLintingCallback is only called when necessary.

Verification successful

The review of the usage of updateLintingCallback in the file app/client/src/components/editorComponents/CodeEditor/index.tsx shows that the function is called conditionally, ensuring it is only executed when necessary. Here are the key points:

  • The callback is assigned once and used in several places, each guarded by conditions checking its existence and other relevant states (like dataTreePath and editor).
  • This conditional usage aligns with best practices for such callbacks, ensuring they do not execute unless their conditions are met.

Based on this, the implementation adheres to the intended usage pattern.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `updateLintingCallback` is only called when necessary.

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type typescript $'updateLintingCallback'

Length of output: 79



Script:

#!/bin/bash
# Description: Verify that the `updateLintingCallback` is only called when necessary.

# Corrected Test: Search for the function usage with the correct file type for TypeScript.
rg --type ts 'updateLintingCallback'

Length of output: 769


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added the Bug Something isn't working label May 13, 2024
@ApekshaBhosale ApekshaBhosale added the ok-to-test Required label for CI label May 13, 2024
Copy link
Contributor

@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: 1

Comment on lines +1443 to +1448
this.annotations = getLintAnnotations(editor.getValue(), lintErrors, {
isJSObject,
contextData,
});

this.updateLintingCallback(editor, annotations);
this.updateLintingCallback(editor, this.annotations);
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor the lintCode function to improve clarity and maintainability.

-    this.annotations = getLintAnnotations(editor.getValue(), lintErrors, {
-      isJSObject,
-      contextData,
-    });
-
-    this.updateLintingCallback(editor, this.annotations);
+    const annotations = getLintAnnotations(editor.getValue(), lintErrors, {
+      isJSObject,
+      contextData,
+    });
+    this.updateLintingCallback(editor, annotations);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
this.annotations = getLintAnnotations(editor.getValue(), lintErrors, {
isJSObject,
contextData,
});
this.updateLintingCallback(editor, annotations);
this.updateLintingCallback(editor, this.annotations);
const annotations = getLintAnnotations(editor.getValue(), lintErrors, {
isJSObject,
contextData,
});
this.updateLintingCallback(editor, annotations);

@dvj1988 dvj1988 merged commit 77193b6 into release May 14, 2024
88 of 89 checks passed
@dvj1988 dvj1988 deleted the linting-markings-disappearing branch May 14, 2024 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants