diff --git a/doc/FileExt.txt b/doc/FileExt.txt index 2c1d29452e..154f6bee0f 100644 --- a/doc/FileExt.txt +++ b/doc/FileExt.txt @@ -265,6 +265,7 @@ Config File CSV File csv + tsv D Source diff --git a/src/EditLexers/stlDefault.cpp b/src/EditLexers/stlDefault.cpp index 9455a6d8ee..d550b644fc 100644 --- a/src/EditLexers/stlDefault.cpp +++ b/src/EditLexers/stlDefault.cpp @@ -199,7 +199,7 @@ EDITLEXER lexCSV = { 0, 0, //CSV Settings--Autogenerated -- end of section automatically generated EDITLEXER_HOLE(L"CSV File", Styles_CSV), - L"csv", + L"csv; tsv", &Keywords_NULL, Styles_CSV }; diff --git a/src/Styles.cpp b/src/Styles.cpp index 4f26edde0b..25e68a7c4a 100644 --- a/src/Styles.cpp +++ b/src/Styles.cpp @@ -291,6 +291,7 @@ static WCHAR favoriteSchemesConfig[MAX_FAVORITE_SCHEMES_CONFIG_SIZE]; // Currently used lexer PEDITLEXER pLexCurrent = &lexTextFile; int np2LexLangIndex = 0; +static bool tabSeparatedValue; // for TSV file static int iCsvOption = ('\"' << 8) | ','; #define CsvOption_BackslashEscape (1 << 15) @@ -2402,6 +2403,13 @@ static void Style_UpdateLexerLang(LPCEDITLEXER pLex, LPCWSTR lpszExt, LPCWSTR lp } break; + case NP2LEX_CSV: + if (StrCaseEqual(L"tsv", lpszExt)) { + tabSeparatedValue = true; + iCsvOption = ('\"' << 8) | '\t'; + } + break; + case NP2LEX_HTML: if (StrCaseEqual(L"jsp", lpszExt)) { np2LexLangIndex = IDM_LEXER_JSP; @@ -2619,6 +2627,7 @@ bool Style_SetLexerFromFile(LPCWSTR lpszFile) noexcept { LPCWSTR lpszExt = nullptr; PEDITLEXER pLexNew = nullptr; PEDITLEXER pLexSniffed; + tabSeparatedValue = false; if (bAutoSelect) { pLexNew = Style_GetLexerFromFile(lpszFile, !fNoCGIGuess, &lpszExt, &bDotFile); @@ -2722,7 +2731,7 @@ bool Style_SetLexerFromFile(LPCWSTR lpszFile) noexcept { pLexNew = pLexArray[iDefaultLexerIndex]; } // Apply the new lexer - if (pLexNew->iLexer == SCLEX_CSV) { + if (pLexNew->iLexer == SCLEX_CSV && !tabSeparatedValue) { Style_SniffCSV(); } Style_SetLexer(pLexNew, true);