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: view zone position in diffEditor with hidden area #139785

Closed
wants to merge 1 commit into from

Conversation

ensorrow
Copy link

@ensorrow ensorrow commented Dec 27, 2021

This PR helps with #3562, fixing the problem of view zone position calculation in diff editor with hidden areas on both sides.


To achieve the goal of collapsing unchanged areas in diff editor, a possible solution is hiding the same lines' area by using setHiddenAreas api in diff editor and then using view zone widget to control the uncollapse behavior:

image

image

VS Code (monaco) produces view zones on the other side by using the relative line-number of original/modified editor view zones. When we call setHiddenAreas on the editors, the line-number used to place the generated view zones would be inaccurate, which will cause mismatch of whitespaces and view zones:

image

This PR calculates the actual line number from the relative line-number and hidden area info, fixing the mismatch problem.

@ghost
Copy link

ghost commented Dec 27, 2021

CLA assistant check
All CLA requirements met.

viewZoneLineNumber = originalEquivalentLineNumber - modifiedEquivalentLineNumber + modifiedForeignVZ.current.afterLineNumber;
const actualAfterLineNumber = this.getActualLineNumber(modifiedForeignVZ.current.afterLineNumber, originalHiddenRanges);
if (actualAfterLineNumber <= originalEquivalentLineNumber) {
viewZoneLineNumber = modifiedEquivalentLineNumber - originalEquivalentLineNumber + actualAfterLineNumber;

Choose a reason for hiding this comment

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

This should be a typo, the correct one is

Suggested change
viewZoneLineNumber = modifiedEquivalentLineNumber - originalEquivalentLineNumber + actualAfterLineNumber;
viewZoneLineNumber = originalEquivalentLineNumber - modifiedEquivalentLineNumber + actualAfterLineNumber;

@hediet hediet added this to the April 2023 milestone Apr 13, 2023
@hediet hediet modified the milestones: April 2023, May 2023 Apr 24, 2023
@hediet
Copy link
Member

hediet commented May 26, 2023

Closing due to #183535.
Also, I'm not entirely sure what this PR actually implements.

@hediet hediet closed this May 26, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants