Skip to content

fix: unset underline style rule - #686

Open
abnormal749 wants to merge 1 commit into
charmbracelet:mainfrom
abnormal749:fix-unset-underline-rule
Open

fix: unset underline style rule#686
abnormal749 wants to merge 1 commit into
charmbracelet:mainfrom
abnormal749:fix-unset-underline-rule

Conversation

@abnormal749

Copy link
Copy Markdown
  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

Summary

Fix Style.UnsetUnderline() so it actually removes the underline style rule instead of setting underline to false.

Problem

UnsetUnderline() currently calls Underline(false). That makes rendered text stop using underline, but internally it still leaves the underline property marked as explicitly set.

That matters when using Inherit(): inherited values are only copied when the child style has not already set that property.

Before this change, a style that called UnsetUnderline() could not inherit underline from a parent style.

Example

parent := lipgloss.NewStyle().Underline(true)

child := lipgloss.NewStyle().
    Underline(true).
    UnsetUnderline().
    Inherit(parent)

Expected: child inherits underline from parent.

Before this fix: child does not inherit underline, because UnsetUnderline() leaves an explicit "underline off" rule behind.

Fix

UnsetUnderline() now clears the underline property directly and resets the stored underline value to UnderlineNone.

This keeps UnsetUnderline() consistent with other unset methods such as UnsetBold(), UnsetItalic(), and UnsetStrikethrough().

Tests

Added a focused test covering the difference between:

  • Underline(false): explicitly disables underline and blocks inheritance.
  • UnsetUnderline(): removes the underline rule and allows inheritance.

Validation

go test . -run 'TestUnsetUnderlineAllowsInheritance|TestStyleUnset|TestStyleInherit'
go test ./...
git diff --checkk

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