Menu

#1262 [PATCH] Enhance raw string identifier styling in Nim

Committed
closed
5
2019-03-07
2019-01-30
Jad Altahan
No

This patch implements the property lexer.nim.raw.strings.highlight.ident.

Saw this behaviour implemented in VS Code and thought it could be a useful for users who'd prefer to see generalized raw string identifiers given the same color as the string literal.

img1

Img2

Code in the image:

# Standard raw string identifier:
let standardDoubleLitRawStr = R"A raw string\"
let standardTripleLitRawStr = R"""A triple-double raw string\""""

# The style of 'customIdent' is determined by the property state
# of lexer.nim.raw.strings.highlight.ident
let customDoubleLitRawStr = customIdent"A string\"
let customTripleLitRawStr = customIdent"""A triple-double raw string\""""
2 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2019-01-31

    The patch calls the ctype.h function isalpha on sc.ch which may be out-of-bounds so may cause undefined behaviour. First check with IsASCII or a numeric range check.

    Due to the potential for undefined behaviour with the functions declared in ctype.h, its best to avoid it completely.

     
  • Jad Altahan

    Jad Altahan - 2019-02-01

    Good to know. I added the ASCII numeric range check function IsLetter(const int ch) in response.

    The attached is a fresh patch for the feature.

     
  • Neil Hodgson

    Neil Hodgson - 2019-02-01
     
  • Neil Hodgson

    Neil Hodgson - 2019-02-01

    The x.nim.styled looks wrong as there is a {3} at the start of the second comment line despite no intervening style change from the previous {3}. That then fails the check which is based on text equality.

    With that fixed, committed as [1eeda6].

     

    Related

    Commit: [1eeda6]

  • Neil Hodgson

    Neil Hodgson - 2019-03-07
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.