From 733898e013826f303d0120deaa2d6d8b140d0f4a Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Fri, 11 Jan 2019 22:04:52 +0100 Subject: [PATCH] more informative dump function --- src/dfmt/indentation.d | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dfmt/indentation.d b/src/dfmt/indentation.d index d2be341..ce39c79 100644 --- a/src/dfmt/indentation.d +++ b/src/dfmt/indentation.d @@ -218,13 +218,16 @@ struct IndentStack /** * Dumps the current state of the indentation stack to `stderr`. Used for debugging. */ - void dump(string file = __FILE__, uint line = __LINE__) + void dump(size_t pos = size_t.max, string file = __FILE__, uint line = __LINE__) { import dparse.lexer : str; import std.algorithm.iteration : map; import std.stdio : stderr; - stderr.writefln("\033[31m%s:%d %(%s %)\033[0m", file, line, arr[0 .. index].map!(a => str(a))); + if (pos == size_t.max) + stderr.writefln("\033[31m%s:%d %(%s %)\033[0m", file, line, arr[0 .. index].map!(a => str(a))); + else + stderr.writefln("\033[31m%s:%d at %d %(%s %)\033[0m", file, line, pos, arr[0 .. index].map!(a => str(a))); } private: