Skip to content

Conversation

@ianyong
Copy link
Member

@ianyong ianyong commented Sep 2, 2023

Description

In #2269 & #2346, the behaviour of breakpoints was updated to be consistent with most code editors & IDEs available. However, due to the way the Editor component and the workspaces are implemented, the Editor maintains its own source of truth that is separate from the Redux store. The bug in #2646 occurs when the breakpoints state in the Redux store and the Editor component become unsynchronised.

To fix this issue, we write the current Editor breakpoints state to the Redux store whenever the Editor value updates. Ideally, the Editor should rely on the Redux store as the single source of truth, but this would require major refactoring and I'm not confident of not breaking other things along the way due to the lack of comprehensive tests + the rather hacky implementation of the Editor.

Fixes #2646.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Replicate

Checklist

  • I have (manually) tested this code
  • I have updated the documentation

Ideally, I would write regression tests here, but testing this particular logic requires some test framework that can simulate user input such as Cypress (and setting up such a test framework is beyond the scope of this PR).

@ianyong ianyong requested a review from martin-henz September 2, 2023 14:07

// Write editor state for the active editor tab to the store.
handleEditorValueChange(props.editorTabIndex, newCode);
handleEditorUpdateBreakpointsRef.current(
Copy link
Member Author

@ianyong ianyong Sep 2, 2023

Choose a reason for hiding this comment

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

No idea why this callback function is wrapped in a ref but I'm afraid that removing it will cause some other regression elsewhere.

Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

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

Looks good. Fixes the example in #2646

@martin-henz martin-henz merged commit 7cea131 into master Sep 3, 2023
@martin-henz martin-henz deleted the fix-breakpoints-state-going-out-of-sync branch September 3, 2023 03:11
RichDom2185 pushed a commit to NUS-CS1101S/cadet-frontend that referenced this pull request Sep 10, 2023
Co-authored-by: Martin Henz <henz@comp.nus.edu.sg>
RichDom2185 pushed a commit to NUS-CS1101S/cadet-frontend that referenced this pull request Sep 10, 2023
Co-authored-by: Martin Henz <henz@comp.nus.edu.sg>
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.

Spurious invisible breakpoints are causing errors

3 participants