diff --git a/CotEditor/Sources/LayoutManager.swift b/CotEditor/Sources/LayoutManager.swift index b1e7f8b211..b034dd65d0 100644 --- a/CotEditor/Sources/LayoutManager.swift +++ b/CotEditor/Sources/LayoutManager.swift @@ -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) diff --git a/CotEditor/Sources/Theme.swift b/CotEditor/Sources/Theme.swift index 609b40c720..1b3962c73e 100644 --- a/CotEditor/Sources/Theme.swift +++ b/CotEditor/Sources/Theme.swift @@ -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 } diff --git a/Tests/ThemeTests.swift b/Tests/ThemeTests.swift index ec558d3e0f..ba238828e2 100644 --- a/Tests/ThemeTests.swift +++ b/Tests/ThemeTests.swift @@ -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. @@ -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 {