Fix #169
This commit is contained in:
parent
8639e4c287
commit
6fb035ff8b
4
makefile
4
makefile
|
@ -1,6 +1,7 @@
|
|||
SRC := $(shell find src -name "*.d") $(shell find libdparse/src -name "*.d")
|
||||
INCLUDE_PATHS := -Ilibdparse/src -Isrc
|
||||
DMD_COMMON_FLAGS := -dip25 -w $(INCLUDE_PATHS)
|
||||
DMD_DEBUG_FLAGS := -g $(DMD_COMMON_FLAGS)
|
||||
DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS)
|
||||
DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS)
|
||||
LDC_FLAGS := -g -w -oq $(INCLUDE_PATHS)
|
||||
|
@ -25,3 +26,6 @@ bin/dfmt-test: $(SRC)
|
|||
|
||||
bin/dfmt: $(SRC)
|
||||
dmd $(DMD_FLAGS) $^ -of$@
|
||||
|
||||
debug: $(SRC)
|
||||
dmd $(DMD_DEBUG_FLAGS) $^ -ofbin/dfmt
|
||||
|
|
|
@ -596,26 +596,28 @@ private:
|
|||
}
|
||||
else
|
||||
{
|
||||
indents.popWrapIndents();
|
||||
if (indents.length && isTempIndent(indents.top))
|
||||
indentLevel = indents.indentLevel - 1;
|
||||
else
|
||||
indentLevel = indents.indentLevel;
|
||||
|
||||
if (!peekBackIsSlashSlash())
|
||||
if (peekBackIsSlashSlash())
|
||||
{
|
||||
if (peekBack2Is(tok!";"))
|
||||
{
|
||||
indents.popTempIndents();
|
||||
indentLevel = indents.indentLevel - 1;
|
||||
}
|
||||
writeToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (indents.length && isTempIndent(indents.top))
|
||||
indentLevel = indents.indentLevel - 1;
|
||||
else
|
||||
indentLevel = indents.indentLevel;
|
||||
if (config.dfmt_brace_style == BraceStyle.allman || peekBackIsOneOf(true, tok!"{", tok!"}"))
|
||||
newline();
|
||||
else if (!peekBackIsOneOf(true, tok!"{", tok!"}", tok!";"))
|
||||
write(" ");
|
||||
writeToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
writeToken();
|
||||
indents.popTempIndents();
|
||||
indentLevel = indents.indentLevel - 1;
|
||||
}
|
||||
|
||||
indents.push(tok!"{");
|
||||
if (!currentIs(tok!"{"))
|
||||
newline();
|
||||
|
@ -1113,7 +1115,7 @@ private:
|
|||
else if (currentIs(tok!"{"))
|
||||
{
|
||||
indents.popWrapIndents();
|
||||
if (peekBackIsSlashSlash())
|
||||
if (peekBackIsSlashSlash() && peekBack2Is(tok!";"))
|
||||
{
|
||||
indents.popTempIndents();
|
||||
indentLevel = indents.indentLevel;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
unittest
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
if (true) // comment
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
unittest
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
if (true) // comment
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
unittest {
|
||||
if (true) {
|
||||
if (true) // comment
|
||||
{
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue