Skip to content

Commit

Permalink
Change DefaultScheme preference to lexer resource id other than lexer…
Browse files Browse the repository at this point in the history
… index, which is stable than the later:

lexer index will changed after adding new lexers.

TODO: change this preference to a more stable ID value, possible solution is using multi-character constant
like 'cpp' (0x637070) for C/C++, 'text' (0x74657874) for Text File, etc.
  • Loading branch information
zufuliu committed Mar 21, 2020
1 parent c2473d1 commit a76f431
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ void Style_Load(void) {

// default scheme
int iValue = IniSectionGetInt(pIniSection, L"DefaultScheme", 0);
iDefaultLexer = clamp_i(iValue, 0, NUMLEXERS - 1);
iDefaultLexer = Style_GetEditLexerId(iValue + NP2LEX_TEXTFILE);

iValue = IniSectionGetInt(pIniSection, L"StyleTheme", StyleTheme_Default);
np2StyleTheme = clamp_i(iValue, StyleTheme_Default, StyleTheme_Max);
Expand Down Expand Up @@ -722,7 +722,7 @@ void Style_Save(void) {
IniSectionSetBoolEx(pIniSection, L"Use2ndGlobalStyle", bUse2ndGlobalStyle, 0);

// default scheme
IniSectionSetIntEx(pIniSection, L"DefaultScheme", iDefaultLexer, 0);
IniSectionSetIntEx(pIniSection, L"DefaultScheme", pLexArray[iDefaultLexer]->rid - NP2LEX_TEXTFILE, 0);
IniSectionSetIntEx(pIniSection, L"StyleTheme", np2StyleTheme, StyleTheme_Default);

// auto select
Expand Down

0 comments on commit a76f431

Please sign in to comment.