Skip to content

Underline red snippet output in no-color mode

Nicolas Phan requested to merge no_color_underline into dev

Motivation and Context

LIGO error messages contain code snippets where the piece of code concerned is colored in red.

Since coloration is disabled when --no-color is used, a replacement for "red" highlighting of output was desired.

This MR underlines output with ^^^ as a replacement for red coloring, when the --no-color flag is used.

Description

Component

  • compiler
  • website
  • webide
  • vscode-plugin
  • debugger

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

For the following piece of code, with a string that has nothing to do here :

let main {| I should be underlined in
  error message with no-color and
  I am a long message spreading
  on 4 lines |} blah-blah

Before

> ligo compile contract --no-color contract.mligo
File "contract.mligo", line 2, character 9 to line 5, character 15:
  1 | 
  2 | let main {| I should be underlined in
  3 |   error message with no-color and
  4 |   I am a long message spreading
  5 |   on 4 lines |} blah-blah
Ill-formed value declaration.
At this point, one of the following is expected:
  * parameters as irrefutable patterns, e.g. variables, if defining a
    function;
  * the assignment symbol '=' followed by an expression;
  * a type annotation starting with a colon ':';
  * a comma ',' followed by another tuple component, if defining a
    tuple.

After

> ligo compile contract --no-color contract.mligo
File "contract.mligo", line 2, character 9 to line 5, character 15:
  1 | 
  2 | let main {| I should be underlined in
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  3 |   error message with no-color and
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  4 |   I am a long message spreading
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5 |   on 4 lines |} blah-blah
      ^^^^^^^^^^^^^^^
Ill-formed value declaration.
At this point, one of the following is expected:
  * parameters as irrefutable patterns, e.g. variables, if defining a
    function;
  * the assignment symbol '=' followed by an expression;
  * a type annotation starting with a colon ':';
  * a comma ',' followed by another tuple component, if defining a
    tuple.

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).

Merge request reports