Skip to content

Commit 9bc40cb

Browse files
committed
Add merge logic for all config options
FIX: Multiple configurations to `linter` will now be merged without raising an error. Closes codemirror/dev#1622
1 parent 4f3adcf commit 9bc40cb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/lint.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,28 @@ const lintConfig = Facet.define<{source: LintSource | null, config: LintConfig},
394394
needsRefresh: null,
395395
hideOn: () => null,
396396
}, {
397-
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
397+
delay: Math.max,
398+
markerFilter: combineFilter,
399+
tooltipFilter: combineFilter,
400+
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u),
401+
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
402+
autoPanel: (a, b) => a || b
398403
})
399404
}
400405
}
401406
})
402407

408+
function combineFilter(a: DiagnosticFilter | null, b: DiagnosticFilter | null): DiagnosticFilter | null {
409+
return !a ? b : !b ? a : (d, s) => b(a(d, s), s)
410+
}
411+
403412
/// Given a diagnostic source, this function returns an extension that
404413
/// enables linting with that source. It will be called whenever the
405-
/// editor is idle (after its content changed). If `null` is given as
406-
/// source, this only configures the lint extension.
414+
/// editor is idle (after its content changed).
415+
///
416+
/// Note that settings given here will apply to all linters active in
417+
/// the editor. If `null` is given as source, this only configures the
418+
/// lint extension.
407419
export function linter(
408420
source: LintSource | null,
409421
config: LintConfig = {}

0 commit comments

Comments
 (0)