mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-28 14:19:56 +03:00
Fix #58
This commit is contained in:
parent
0d496129be
commit
3df6515755
3 changed files with 35 additions and 1 deletions
18
src/dfmt.d
18
src/dfmt.d
|
@ -1021,6 +1021,22 @@ private:
|
||||||
return peekImplementation(tokenType, 0, ignoreComments);
|
return peekImplementation(tokenType, 0, ignoreComments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bugs: not unicode correct
|
||||||
|
size_t tokenEndLine(const Token t)
|
||||||
|
{
|
||||||
|
import std.algorithm : count;
|
||||||
|
switch (t.type)
|
||||||
|
{
|
||||||
|
case tok!"comment":
|
||||||
|
case tok!"stringLiteral":
|
||||||
|
case tok!"wstringLiteral":
|
||||||
|
case tok!"dstringLiteral":
|
||||||
|
return t.line + (cast(ubyte[]) t.text).count('\n');
|
||||||
|
default:
|
||||||
|
return t.line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool isBlockHeader(int i = 0)
|
bool isBlockHeader(int i = 0)
|
||||||
{
|
{
|
||||||
if (i + index < 0 || i + index >= tokens.length)
|
if (i + index < 0 || i + index >= tokens.length)
|
||||||
|
@ -1039,7 +1055,7 @@ private:
|
||||||
output.put("\n");
|
output.put("\n");
|
||||||
immutable bool hasCurrent = index + 1 < tokens.length;
|
immutable bool hasCurrent = index + 1 < tokens.length;
|
||||||
if (!justAddedExtraNewline && index > 0
|
if (!justAddedExtraNewline && index > 0
|
||||||
&& hasCurrent && tokens[index].line - tokens[index - 1].line > 1)
|
&& hasCurrent && tokens[index].line - tokenEndLine(tokens[index - 1]) > 1)
|
||||||
{
|
{
|
||||||
output.put("\n");
|
output.put("\n");
|
||||||
}
|
}
|
||||||
|
|
9
tests/issue0058.d
Normal file
9
tests/issue0058.d
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
/********************************************************
|
||||||
|
* Helper function for checkAccess()
|
||||||
|
* Returns:
|
||||||
|
* false is not accessible
|
||||||
|
* true is accessible
|
||||||
|
*/
|
||||||
|
extern (C++) static bool isAccessible()
|
||||||
|
{
|
||||||
|
}
|
9
tests/issue0058.d.ref
Normal file
9
tests/issue0058.d.ref
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
/********************************************************
|
||||||
|
* Helper function for checkAccess()
|
||||||
|
* Returns:
|
||||||
|
* false is not accessible
|
||||||
|
* true is accessible
|
||||||
|
*/
|
||||||
|
extern (C++) static bool isAccessible()
|
||||||
|
{
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue