public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH guest-common] GuestHelpers: fix snapshot indentation length
Date: Mon, 28 Feb 2022 15:46:46 +0100	[thread overview]
Message-ID: <20220228144646.1517147-1-d.csapak@proxmox.com> (raw)

if a user has many snapshots, the length goes negative and produces
wrong indentation, so clamp it at 0

reported by a user in the forum:
https://forum.proxmox.com/threads/non-threaded-listsnaphost-view.105740/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
for many snapshots this still looks weird, but has a consistent indentation.
to do it completely right, we'd have to iterate twice and find the
longest line first and use that as width for the first column. not
sure if worth the effort.

 src/PVE/GuestHelpers.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm
index 970c460..0c8ed66 100644
--- a/src/PVE/GuestHelpers.pm
+++ b/src/PVE/GuestHelpers.pm
@@ -157,6 +157,7 @@ sub print_snapshot_tree {
 	}
 
 	my $len = 30 - length($prefix); # for aligning the description
+	$len = 0 if $len < 0;
 	printf("%s %-${len}s %-23s %s\n", $prefix, $root, $timestring, $description);
 
 	if ($e->{children}) {
-- 
2.30.2





             reply	other threads:[~2022-02-28 14:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 14:46 Dominik Csapak [this message]
2022-03-01 12:13 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220228144646.1517147-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal