Skip to content

Commit

Permalink
Fix headCharAfterIndention value
Browse files Browse the repository at this point in the history
And also save a function call
  • Loading branch information
Chocobo1 committed Aug 24, 2018
1 parent 572e78b commit 6ed93f5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/nppAutoDetectIndent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "settings.h"

#define PLUGIN_VERSION "1.3"
#define PLUGIN_VERSION "1.4"

namespace
{
Expand Down Expand Up @@ -53,6 +53,18 @@ namespace
}
}

template <typename CharArray>
char findFirstCharAfterIndention(const CharArray &str)
{
for (const char c : str)
{
if (c == '\t' || c == ' ')
continue;
return c;
}
return -1;
}

struct IndentionStats
{
int tabCount = 0;
Expand Down Expand Up @@ -87,11 +99,12 @@ namespace
Sci_TextRange textRange;
setupSciTextRange(textRange, pos, (pos + indentWidth + 1), textRangeBuffer.data());
sci.call<int>(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&textRange));
const char headCharAfterIndention = textRangeBuffer[indentWidth];

const char headChar = textRangeBuffer[0];
const char headCharAfterIndention = findFirstCharAfterIndention(textRangeBuffer);
if (isCommentContinuation(langId, headCharAfterIndention))
continue;

const char headChar = sci.call<char>(SCI_GETCHARAT, pos);
if (headChar == '\t')
++result.tabCount;
if (headChar == ' ')
Expand Down

0 comments on commit 6ed93f5

Please sign in to comment.