File tree Expand file tree Collapse file tree
apps/desktop/src-tauri/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,10 +125,16 @@ fn screenshots_path(app: &AppHandle) -> PathBuf {
125125}
126126
127127fn truncate_title ( title : & str ) -> String {
128- if title. len ( ) <= MAX_TITLE_LENGTH {
128+ if title. chars ( ) . count ( ) <= MAX_TITLE_LENGTH {
129129 title. to_string ( )
130130 } else {
131- format ! ( "{}…" , & title[ ..MAX_TITLE_LENGTH - 1 ] )
131+ let truncate_at = MAX_TITLE_LENGTH - 1 ;
132+ let byte_index = title
133+ . char_indices ( )
134+ . nth ( truncate_at)
135+ . map ( |( i, _) | i)
136+ . unwrap_or ( title. len ( ) ) ;
137+ format ! ( "{}…" , & title[ ..byte_index] )
132138 }
133139}
134140
@@ -178,7 +184,7 @@ fn load_single_item(
178184 let created_at = path
179185 . metadata ( )
180186 . and_then ( |m| m. created ( ) )
181- . unwrap_or ( std:: time:: SystemTime :: UNIX_EPOCH ) ;
187+ . unwrap_or_else ( |_| std:: time:: SystemTime :: now ( ) ) ;
182188
183189 let is_screenshot = path. extension ( ) . and_then ( |s| s. to_str ( ) ) == Some ( "cap" )
184190 && path. parent ( ) . map ( |p| p == screenshots_dir) . unwrap_or ( false ) ;
You can’t perform that action at this time.
0 commit comments