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: indent guides causes 1px drift in word wrapped lines #2111

Merged
merged 1 commit into from
Feb 3, 2025
Merged

fix: indent guides causes 1px drift in word wrapped lines #2111

merged 1 commit into from
Feb 3, 2025

Conversation

abose
Copy link
Member

@abose abose commented Feb 3, 2025

Users reported that deeply indented HTML elements caused misalignment between the text inside elements and their corresponding tags. The issue worsened as indentation depth increased, resulting in a noticeable shift of approximately one or two spaces at deep indentation levels.

Closes

Fixes https://github.com/orgs/phcode-dev/discussions/2108

Root Cause

Previously, the .cm-phcode-indent-guides::before selector was used to create indent guides via a border-left:

.cm-phcode-indent-guides::before {
    content: " ";
    width: 1px;
    display: inline-block;
    position: relative;
    border-left: 1px solid rgba(128, 128, 128, 0.3);
}

However, this approach added a 1px tax per indentation level, meaning that each additional indent slightly shifted the text outward. The cumulative effect of this offset became more noticeable with deeper indentation.

Fix

Replaced the border-left approach with an inset box-shadow, which does not affect inline layout calculations but still visually maintains the indentation guides:

.cm-phcode-indent-guides {
    box-shadow: inset 1px 0 0 rgba(128, 128, 128, 0.3);
}

This ensures:

  • No extra inline width tax per indentation level.
  • The indentation guides remain visually identical.
  • The text inside elements remains properly aligned regardless of depth.

Testing

  • Verified that indentation no longer misaligns text at deep levels.
  • Ensured indent guides still render correctly.
  • Checked that line wrapping behavior remains unaffected.
  • Since this is a css change for visual verification, automated tests not written as not possible, except maybe with ai image recognition in the future.

Copy link

sonarqubecloud bot commented Feb 3, 2025

@abose abose merged commit de5356d into main Feb 3, 2025
17 of 18 checks passed
@abose abose deleted the x branch February 3, 2025 04:38
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.

1 participant