Skip to content

Assertion failure about colors #28

@langston-barrett

Description

@langston-barrett
src/term.c:182: term_set_attr: Assertion `attr.x.color == term->attr.x.color || attr.x.color == IC_COLOR_NONE' failed.

assert(attr.x.color == term->attr.x.color || attr.x.color == IC_COLOR_NONE);

Here's what my Haskell code looks like:

readIsocline :: CommandExt cExt -> IO String
readIsocline cExts = do
  let extraPrompt = ""  -- prompt will be "> "
  Isocline.readlineEx
    extraPrompt
    (Just completer)
    (Just highlighter)
  where
    allCmdNames :: [String]
    allCmdNames = map (Text.unpack . Cmd.name cExts) (Cmd.allCmds cExts)

    completer :: Isocline.CompletionEnv -> String -> IO () 
    completer cEnv input = do
      let roots = ["."]
      let exts = []  -- any extension
      let dirSep = Nothing  -- system
      Isocline.completeFileName cEnv input dirSep roots exts

      let isWordChar = Nothing -- default
      let wordCompleter inp = Isocline.completionsFor inp allCmdNames
      Isocline.completeWord cEnv input isWordChar wordCompleter

    allCmdSet :: Set String
    allCmdSet = Set.fromList allCmdNames

    highlighter :: String -> Isocline.Fmt
    highlighter input =
      case words input of
        (cmd : args) ->
          if cmd `Set.member` allCmdSet
          then unwords (Isocline.style "bold" cmd : args)
          else input
        [] -> input

The same thing happens when you replace bold with cyan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions