Skip to content

Commit

Permalink
Avoid auto completing braces and quotes in escape sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jan 3, 2019
1 parent f22d86b commit f7d520b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/EditAutoC.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,7 @@ void EditCompleteWord(HWND hwnd, BOOL autoInsert) {

static BOOL CanAutoCloseSingleQuote(int chPrev, int iCurrentStyle) {
const int iLexer = pLexCurrent->iLexer;
if (chPrev == '\\' // character
|| chPrev > 0x7F // someone's
if (chPrev > 0x7F // someone's
|| (iLexer == SCLEX_CPP && iCurrentStyle == SCE_C_NUMBER)
|| (iLexer == SCLEX_LISP && iCurrentStyle == SCE_C_OPERATOR)
|| (iLexer == SCLEX_MATLAB && iCurrentStyle == SCE_MAT_OPERATOR) // transpose operator
Expand All @@ -705,7 +704,7 @@ static BOOL CanAutoCloseSingleQuote(int chPrev, int iCurrentStyle) {
return FALSE;
}

// someone's
// someone's, don't
if (isalnum(chPrev)) {
// character prefix
if (pLexCurrent->rid == NP2LEX_CPP || pLexCurrent->rid == NP2LEX_RC || iLexer == SCLEX_PYTHON || iLexer == SCLEX_SQL) {
Expand Down Expand Up @@ -749,6 +748,11 @@ void EditAutoCloseBraceQuote(HWND hwnd, int ch) {
}
}

// escape sequence
if (ch != ',' && (chPrev == '\\' || (pLexCurrent->iLexer == SCLEX_BATCH && chPrev == '^'))) {
return;
}

const int mask = autoCompletionConfig.fAutoInsertMask;
char tchIns[2] = "";
switch (ch) {
Expand Down Expand Up @@ -776,7 +780,7 @@ void EditAutoCloseBraceQuote(HWND hwnd, int ch) {
}
break;
case '\"':
if ((mask & AutoInsertDoubleQuote) && chPrev != '\\') {
if ((mask & AutoInsertDoubleQuote)) {
tchIns[0] = '\"';
}
break;
Expand Down

0 comments on commit f7d520b

Please sign in to comment.