Skip to content

Commit 14b9a36

Browse files
committed
Fix bug: execOnWorkspaceChange error message
1 parent f98e416 commit 14b9a36

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

Sources/AppBundle/config/parseConfig.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private let configParser: [String: any ParserProtocol<Config>] = [
105105
"start-at-login": Parser(\.startAtLogin, parseBool),
106106
"automatically-unhide-macos-hidden-apps": Parser(\.automaticallyUnhideMacosHiddenApps, parseBool),
107107
"accordion-padding": Parser(\.accordionPadding, parseInt),
108-
"exec-on-workspace-change": Parser(\.execOnWorkspaceChange, parseExecOnWorkspaceChange),
108+
"exec-on-workspace-change": Parser(\.execOnWorkspaceChange, parseArrayOfStrings),
109109
"exec": Parser(\.execConfig, parseExecConfig),
110110

111111
keyMappingConfigRootKey: Parser(\.keyMapping, skipParsing(Config().keyMapping)), // Parsed manually
@@ -289,10 +289,12 @@ private func skipParsing<T: Sendable>(_ value: T) -> @Sendable (_ raw: TOMLValue
289289
{ _, _ in .success(value) }
290290
}
291291

292-
private func parseExecOnWorkspaceChange(_ raw: TOMLValueConvertible, _ backtrace: TomlBacktrace) -> ParsedToml<[String]> {
292+
private func parseArrayOfStrings(_ raw: TOMLValueConvertible, _ backtrace: TomlBacktrace) -> ParsedToml<[String]> {
293293
parseTomlArray(raw, backtrace)
294294
.flatMap { arr in
295-
arr.mapAllOrFailure { elem in parseString(elem, backtrace) }
295+
arr.enumerated().mapAllOrFailure { (index, elem) in
296+
parseString(elem, backtrace + .index(index))
297+
}
296298
}
297299
}
298300

Sources/AppBundleTests/config/ConfigTest.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ final class ConfigTest: XCTestCase {
1919
assertEquals(errors, [])
2020
}
2121

22+
func testExecOnWorkspaceChangeDifferentTypesError() {
23+
let (_, errors) = parseConfig(
24+
"""
25+
exec-on-workspace-change = ['', 1]
26+
""",
27+
)
28+
assertEquals(errors.descriptions, ["exec-on-workspace-change[1]: Expected type is \'string\'. But actual type is \'integer\'"])
29+
}
30+
2231
func testQueryCantBeUsedInConfig() {
2332
let (_, errors) = parseConfig(
2433
"""

0 commit comments

Comments
 (0)