mirror of
				https://github.com/talwat/lowfi
				synced 2025-10-30 18:58:45 +00:00 
			
		
		
		
	fix: use unicode-segmentation to fix issues with unicode track names
This commit is contained in:
		
							parent
							
								
									6ff41e0e34
								
							
						
					
					
						commit
						5057721913
					
				
							
								
								
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -1471,6 +1471,7 @@ dependencies = [ | ||||
|  "rodio", | ||||
|  "scraper", | ||||
|  "tokio", | ||||
|  "unicode-segmentation", | ||||
|  "unicode-width 0.2.0", | ||||
|  "url", | ||||
| ] | ||||
| @ -2778,6 +2779,12 @@ version = "1.0.14" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "unicode-segmentation" | ||||
| version = "1.12.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "unicode-width" | ||||
| version = "0.1.14" | ||||
|  | ||||
| @ -51,3 +51,4 @@ lazy_static = "1.5.0" | ||||
| libc = "0.2.167" | ||||
| url = "2.5.4" | ||||
| unicode-width = "0.2.0" | ||||
| unicode-segmentation = "1.12.0" | ||||
|  | ||||
| @ -4,6 +4,7 @@ | ||||
| use std::{ops::Deref, sync::Arc, time::Duration}; | ||||
| 
 | ||||
| use crossterm::style::Stylize; | ||||
| use unicode_segmentation::UnicodeSegmentation; | ||||
| 
 | ||||
| use crate::{player::Player, tracks::Info}; | ||||
| 
 | ||||
| @ -100,10 +101,10 @@ pub fn action(player: &Player, current: Option<&Arc<Info>>, width: usize) -> Str | ||||
|         }) | ||||
|         .format(); | ||||
| 
 | ||||
|     // TODO: Deal with dangerous string slicing.
 | ||||
|     #[allow(clippy::string_slice)] | ||||
|     if len > width { | ||||
|         format!("{}...", &main[..=width]) | ||||
|         let chopped: String = main.graphemes(true).take(width + 1).collect(); | ||||
| 
 | ||||
|         format!("{}...", chopped) | ||||
|     } else { | ||||
|         format!("{}{}", main, " ".repeat(width - len)) | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user