Skip to content

Commit

Permalink
Fix test for theme
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed May 11, 2024
1 parent b8aae54 commit e329a90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CotEditor/Sources/LayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ class LayoutManager: NSLayoutManager, InvisibleDrawing, ValidationIgnorable, Lin
if color == .unemphasizedSelectedContentBackgroundColor, // check if inactive
let textView = self.textContainer(forGlyphAt: self.glyphIndexForCharacter(at: charRange.location),
effectiveRange: nil, withoutAdditionalLayout: true)?.textView,
let theme = (textView as? any Themable)?.theme
let theme = (textView as? any Themable)?.theme,
let newColor = theme.effectiveSecondarySelectionColor(for: textView.effectiveAppearance),
newColor != color
{
theme.effectiveSecondarySelectionColor(for: textView.effectiveAppearance)?.setFill()
newColor.setFill()
}

super.fillBackgroundRectArray(rectArray, count: rectCount, forCharacterRange: charRange, color: color)
Expand Down
4 changes: 2 additions & 2 deletions CotEditor/Sources/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ struct Theme: Equatable {

if self.selection.usesSystemSetting {
return if self.isDarkTheme == appearance.isDark {
.unemphasizedSelectedTextBackgroundColor
.unemphasizedSelectedContentBackgroundColor
} else {
.unemphasizedSelectedTextBackgroundColor.solve(for: appearance.appearance(for: self.isDarkTheme))
.unemphasizedSelectedContentBackgroundColor.solve(for: appearance.appearance(for: self.isDarkTheme))
}
} else {
guard let color = self.selection.color.usingColorSpace(.genericRGB) else { return nil }
Expand Down
4 changes: 2 additions & 2 deletions Tests/ThemeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2016-2023 1024jp
// © 2016-2024 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,7 +46,7 @@ final class ThemeTests: XCTestCase {
XCTAssertEqual(theme.invisibles.color.brightnessComponent, 0.72, accuracy: 0.01)
XCTAssertEqual(theme.background.color, NSColor.white.usingColorSpace(.genericRGB))
XCTAssertEqual(theme.lineHighlight.color.brightnessComponent, 0.94, accuracy: 0.01)
XCTAssertNil(theme.secondarySelectionColor)
XCTAssertEqual(theme.effectiveSecondarySelectionColor(for: NSAppearance(named: .aqua)!), .unemphasizedSelectedContentBackgroundColor)
XCTAssertFalse(theme.isDarkTheme)

for type in SyntaxType.allCases {
Expand Down

0 comments on commit e329a90

Please sign in to comment.