notepad-plus-plus / notepad-plus-plus

Notepad++ official repository
https://notepad-plus-plus.org/
Other
22.87k stars 4.6k forks source link

Support LESS and SASS #5621

Open asashour opened 5 years ago

asashour commented 5 years ago

Description of the Issue

Highlight of CSS doesn't work with :nth-of-type

Steps to Reproduce the Issue

  1. Open new file in Notepad++
  2. Paste the following to it:
    .abc {
    .chart {
        .labels:nth-of-type(2) {
           top: 10px;
           span {
               left: 0px;
           }
        }
    }
    }
  3. Sets its language to CSS
  4. Go to the parenthesis in line 8

Expected Behavior

The corresponding parenthesis in line 3 should be highlighted.

Actual Behavior

The corresponding parenthesis in line 2 is incorrectly highlighted. image

Debug Information

Notepad++ v7.6.6 (64-bit) Build time : Apr 3 2019 - 23:52:32 Path : C:\Program Files\Notepad++\notepad++.exe Admin mode : OFF Local Conf mode : OFF OS : Windows 7 (64-bit) Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll

This doesn't happen when :nth-of-type(2) is removed.

ArkadiuszMichalski commented 4 years ago

It is rather due to a lack of https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4273. Pure CSS does not support nesting (https://drafts.csswg.org/css-nesting-1/), although in a different way.

Edit: LexerCSS support some preprocessors :

    // property lexer.css.scss.language
    //  Set to 1 for Sassy CSS (.scss)
    bool isScssDocument = styler.GetPropertyInt("lexer.css.scss.language") != 0;

    // property lexer.css.less.language
    // Set to 1 for Less CSS (.less)
    bool isLessDocument = styler.GetPropertyInt("lexer.css.less.language") != 0;

    // property lexer.css.hss.language
    // Set to 1 for HSS (.hss)
    bool isHssDocument = styler.GetPropertyInt("lexer.css.hss.language") != 0;

For above example it's Less and works fine.

a