public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH guest-common] GuestHelpers: fix snapshot indentation length
@ 2022-02-28 14:46 Dominik Csapak
  2022-03-01 12:13 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2022-02-28 14:46 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH guest-common] GuestHelpers: fix snapshot indentation length
  2022-02-28 14:46 [pve-devel] [PATCH guest-common] GuestHelpers: fix snapshot indentation length Dominik Csapak
@ 2022-03-01 12:13 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-03-01 12:13 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 28.02.22 15:46, Dominik Csapak wrote:
> 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.

yeah I think that for now it's OK to not (La)Tex level features here, albeit
it'd not be *that* hard. FWIW, I reduced the space indentation per level from
two to one, looks better that way and allows for more snapshots to be displayed
correctly before clamping kicks in.

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

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-01 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 14:46 [pve-devel] [PATCH guest-common] GuestHelpers: fix snapshot indentation length Dominik Csapak
2022-03-01 12:13 ` [pve-devel] applied: " Thomas Lamprecht

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