Skip to content

Commit

Permalink
Merge pull request #81 from Koihik/dev
Browse files Browse the repository at this point in the history
fix: comment visit twice in some case
  • Loading branch information
Koihik authored Jan 11, 2020
2 parents 310cecb + 6f0843c commit a9aa804
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/FormatVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,9 @@ antlrcpp::Any FormatVisitor::visitPrefixexp(LuaParser::PrefixexpContext* ctx) {
visitVarOrExp(ctx->varOrExp());

string ws = buildFirstArgumentWs(ctx->nameAndArgs());
cur_writer() << commentAfter(ctx->varOrExp(), ws);
if (ctx->nameAndArgs().size() > 0) {
cur_writer() << commentAfter(ctx->varOrExp(), ws);
}

buildArguments(ctx->nameAndArgs());

Expand Down
1 change: 1 addition & 0 deletions test/test_format_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ TEST_FILE(PROJECT_PATH "/test/testdata/issues/issue-62_1.lua");
TEST_FILE(PROJECT_PATH "/test/testdata/issues/issue-62_2.lua");
TEST_FILE(PROJECT_PATH "/test/testdata/issues/issue-62_3.lua");
TEST_FILE(PROJECT_PATH "/test/testdata/issues/issue-70.lua");
TEST_FILE(PROJECT_PATH "/test/testdata/issues/issue-80.lua");

TEST_FILE(PROJECT_PATH "/test/testdata/keep_simple_block_one_line/default.lua");
TEST_FILE(PROJECT_PATH "/test/testdata/keep_simple_block_one_line/keep_simple_function_one_line_false.lua");
Expand Down
2 changes: 2 additions & 0 deletions test/testdata/issues/_issue-80.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
local x =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- hello there
1 change: 1 addition & 0 deletions test/testdata/issues/issue-80.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- hello there

0 comments on commit a9aa804

Please sign in to comment.