From 25ca57dfd7fd053e64cbbf9eef1c3d8aede5ccb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Mon, 31 Oct 2022 09:15:03 +0100
Subject: [PATCH] Fixed path width adaptation

---
 gprompt.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gprompt.pl b/gprompt.pl
index b664e76..6f0e8a2 100644
--- a/gprompt.pl
+++ b/gprompt.pl
@@ -1060,13 +1060,13 @@ sub render_cwd
 
 	my $cwd = $state->{cwd};
 	( my $dir = $cwd ) =~ s!^.*/!!;
+	my $max_len = int( $COLUMNS * $CONFIG{cwd_max_width} / 100 );
+	$max_len = length( $dir ) if length( $dir ) > $max_len;
 	if (exists $state->{home}) {
 		my $home = $state->{home};
 		( $dir = $cwd ) =~ s!^\Q$home\E(\z|/.*)$!~$1!;
 	}
 
-	my $max_len = int( $COLUMNS * $CONFIG{cwd_max_width} / 100 );
-	$max_len = length( $dir ) if length( $dir ) > $max_len;
 	my $offset = length( $dir ) - $max_len;
 	if ( $offset > 0 ) {
 		$dir = substr $dir , $offset , $max_len;