Skip to content

Commit c6e1cb1

Browse files
committed
Fix folder name copying
1 parent f9abe88 commit c6e1cb1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

yazi-shared/src/path/dyn.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ impl<'p> PathLike<'p> for PathDyn<'p> {
125125
}
126126

127127
fn stem(self) -> Option<Self::Strand<'p>> {
128-
Some(match self {
129-
Self::Os(p) => p.file_stem()?.into(),
130-
})
128+
let stem = match self {
129+
Self::Os(p) if p.is_dir() => p.file_name(),
130+
Self::Os(p) => p.file_stem(),
131+
};
132+
stem.map(Into::into)
131133
}
132134

133135
fn try_ends_with<'a, T>(self, child: T) -> Result<bool, EndsWithError>

yazi-shared/src/path/path.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ impl<'p> PathLike<'p> for &'p std::path::Path {
114114

115115
fn parent(self) -> Option<Self> { self.parent() }
116116

117-
fn stem(self) -> Option<Self::Strand<'p>> { self.file_stem() }
117+
fn stem(self) -> Option<Self::Strand<'p>> {
118+
if self.is_dir() { self.file_name() } else { self.file_stem() }
119+
}
118120

119121
fn try_ends_with<'a, T>(self, child: T) -> Result<bool, EndsWithError>
120122
where

0 commit comments

Comments
 (0)