Skip to content

Stan: Avoid terminal colors in messages #3090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ import Ide.Types (PluginDescriptor (..),
defaultPluginDescriptor)
import qualified Language.LSP.Types as LSP
import Stan.Analysis (Analysis (..), runAnalysis)
import Stan.Category (prettyShowCategory)
import Stan.Category (Category (..))
import Stan.Core.Id (Id (..))
import Stan.Inspection (Inspection (..))
import Stan.Inspection.All (inspectionsIds, inspectionsMap)
import Stan.Observation (Observation (..))
import Stan.Severity (prettyShowSeverity)

descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
descriptor recorder plId = (defaultPluginDescriptor plId) {pluginRules = rules recorder}
Expand Down Expand Up @@ -94,15 +93,16 @@ rules recorder = do
let
-- Looking similar to Stan CLI output
-- We do not use `prettyShowInspection` cuz Id is redundant here
-- `prettyShowSeverity` and `prettyShowCategory` would contain color
-- codes and are replaced, too
message :: T.Text
message =
T.unlines $
[ " ✲ Name: " <> inspectionName inspection,
" ✲ Description: " <> inspectionDescription inspection,
" ✲ Severity: " <> (prettyShowSeverity $
inspectionSeverity inspection),
" ✲ Severity: " <> (T.pack $ show $ inspectionSeverity inspection),
" ✲ Category: " <> T.intercalate " "
(map prettyShowCategory $ toList $ inspectionCategory inspection),
(map (("#" <>) . unCategory) $ toList $ inspectionCategory inspection),
"Possible solutions:"
]
++ map (" - " <>) (inspectionSolution inspection)
Expand Down