From f3fe504ed5e0564df1ab81422ab7614a4eebd0df Mon Sep 17 00:00:00 2001 From: Bastiaan Veelo Date: Tue, 16 Oct 2018 21:02:54 +0200 Subject: [PATCH] Allow comments in selective imports. tokenLength() does not consider comments as valid tokens, so get their length explicitly. Fixes issue 384, allowing comments inbetween the symbols of selective imports. --- src/dfmt/formatter.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index ca39597..ef30a25 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -533,7 +533,7 @@ private: { if (tokens[i].type == tok!"," || tokens[i].type == tok!";") break; - const len = tokenLength(tokens[i]); + immutable len = tokens[i].type == tok!"comment" ? tokens[i].text.length : tokenLength(tokens[i]); assert(len >= 0); lengthOfNextChunk += len; }