]> granicus.if.org Git - icinga2/commitdiff
console: Don't repeat line when we're reporting an error for the last line
authorGunnar Beutner <gunnar@beutner.name>
Mon, 9 Feb 2015 14:15:26 +0000 (15:15 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 9 Feb 2015 14:15:26 +0000 (15:15 +0100)
fixes #8099

lib/cli/consolecommand.cpp

index 8161ffc621313643eabdcc750442eabc81295882..3f37dae7a4dee48242bc5aebcf11a19ecab82098 100644 (file)
@@ -110,8 +110,15 @@ int ConsoleCommand::Run(const po::variables_map& vm, const std::vector<std::stri
                                DebugInfo di = ex.GetDebugInfo();
 
                                if (lines.find(di.Path) != lines.end()) {
-                                       std::cout << di.Path << ": " << lines[di.Path] << "\n";
-                                       std::cout << String(di.Path.GetLength() + 2, ' ');
+                                       int offset;
+
+                                       if (di.Path != fileName) {
+                                               std::cout << di.Path << ": " << lines[di.Path] << "\n";
+                                               offset = 2;
+                                       } else
+                                               offset = 4;
+
+                                       std::cout << String(di.Path.GetLength() + offset, ' ');
                                        std::cout << String(di.FirstColumn, ' ') << String(di.LastColumn - di.FirstColumn + 1, '^') << "\n";
                                } else {
                                        ShowCodeFragment(std::cout, di);