Skip to content

Commit 65d4ca4

Browse files
authored
Merge pull request doxygen#11331 from albert-github/feature/issue_11330
issue doxygen#11330 Snippet trimleft option does not handle newlines well
2 parents 8172a20 + 0d3a51a commit 65d4ca4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/codefragment.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void CodeFragmentManager::Private::FragmentInfo::findBlockMarkers()
129129
}
130130
return startPos;
131131
};
132-
static auto lineIndent = [](const char *&ss) -> int
132+
static auto lineIndent = [](const char *&ss, int orgCol) -> int
133133
{
134134
int tabSize=Config_getInt(TAB_SIZE);
135135
int col = 0;
@@ -138,14 +138,15 @@ void CodeFragmentManager::Private::FragmentInfo::findBlockMarkers()
138138
{
139139
if (cc==' ') col++;
140140
else if (cc=='\t') col+=tabSize-(col%tabSize);
141+
else if (cc=='\n') return orgCol;
141142
else
142143
{
143144
// goto end of the line
144145
while ((cc=*ss++) && cc!='\n');
145-
break;
146+
return col;
146147
}
147148
}
148-
return col;
149+
return orgCol;
149150
};
150151
lineNr=1;
151152
const char *startBuf = s;
@@ -158,9 +159,10 @@ void CodeFragmentManager::Private::FragmentInfo::findBlockMarkers()
158159

159160
const char *ss = s;
160161
int minIndent=100000;
162+
int indent = minIndent;
161163
while (ss<e)
162164
{
163-
int indent = lineIndent(ss);
165+
indent = lineIndent(ss, indent);
164166
if (indent<minIndent)
165167
{
166168
minIndent=indent;

0 commit comments

Comments
 (0)