@@ -346,7 +346,7 @@ impl Cli {
346
346
"Unhandled command so unknown session name" . to_string ( )
347
347
}
348
348
} ;
349
- session. set_name ( & possiblename) ? ;
349
+ session. set_name ( & possiblename) ;
350
350
session. name . to_string ( )
351
351
}
352
352
@@ -426,7 +426,6 @@ impl Session {
426
426
/// Takes a string, applies some cleanup, then stores it as
427
427
/// session name, returning the cleaned up value
428
428
#[ tracing:: instrument( level = "trace" ) ]
429
- #[ throws( anyhow:: Error ) ]
430
429
fn set_name ( & mut self , newname : & str ) {
431
430
// Replace a set of characters we do not want in the session name with _
432
431
self . name = newname. replace ( & [ ' ' , ':' , '"' , '.' ] [ ..] , "_" ) ;
@@ -662,7 +661,7 @@ impl Session {
662
661
// as that session name. So we check again, and if
663
662
// a session name like this already exists, we try
664
663
// attaching to it.
665
- self . set_name ( & line) ? ;
664
+ self . set_name ( & line) ;
666
665
if self . exists ( ) {
667
666
info ! ( "Session matches existing one, attaching" ) ;
668
667
self . attach ( ) ?;
@@ -1716,19 +1715,14 @@ mod tests {
1716
1715
..Default :: default ( )
1717
1716
} ;
1718
1717
1719
- assert_eq ! ( "test" , session. set_name( "test" ) . unwrap( ) ) ;
1720
- assert_eq ! ( "test_second" , session. set_name( "test second" ) . unwrap( ) ) ;
1721
- assert_eq ! ( "test_third" , session. set_name( "test:third" ) . unwrap( ) ) ;
1722
- assert_eq ! (
1723
- "test_fourth_fifth" ,
1724
- session. set_name( "test fourth fifth" ) . unwrap( )
1725
- ) ;
1726
- assert_eq ! (
1727
- "test_fourth_fifth_more_words_here_set_in" ,
1728
- session
1729
- . set_name( "test fourth_fifth:more words here\" set in" )
1730
- . unwrap( )
1731
- ) ;
1718
+ session. set_name ( "test" ) ;
1719
+ assert_eq ! ( "test" , session. name) ;
1720
+ session. set_name ( "test second" ) ;
1721
+ assert_eq ! ( "test_second" , session. name) ;
1722
+ session. set_name ( "test:third" ) ;
1723
+ assert_eq ! ( "test_third" , session. name) ;
1724
+ session. set_name ( "test_fourth_fifth_more_words_here\" set_in" ) ;
1725
+ assert_eq ! ( "test_fourth_fifth_more_words_here_set_in" , session. name) ;
1732
1726
}
1733
1727
1734
1728
#[ test]
@@ -1756,7 +1750,7 @@ mod tests {
1756
1750
..Default :: default ( )
1757
1751
} ;
1758
1752
// We want a new session
1759
- session. set_name ( "fakeattach" ) . unwrap ( ) ;
1753
+ session. set_name ( "fakeattach" ) ;
1760
1754
// Shouldn't exist
1761
1755
assert ! ( !session. exists( ) ) ;
1762
1756
// Lets create it
@@ -1788,7 +1782,7 @@ mod tests {
1788
1782
1789
1783
assert ! ( !session. exists( ) ) ;
1790
1784
// And now we test something that shouldn't work for attach
1791
- session. set_name ( "notfakeattach" ) . unwrap ( ) ;
1785
+ session. set_name ( "notfakeattach" ) ;
1792
1786
// Not grouped
1793
1787
session. grouped = false ;
1794
1788
// Shouldn't exist
@@ -1815,7 +1809,7 @@ mod tests {
1815
1809
let mut session = Session {
1816
1810
..Default :: default ( )
1817
1811
} ;
1818
- session. set_name ( "tmtestsession" ) . unwrap ( ) ;
1812
+ session. set_name ( "tmtestsession" ) ;
1819
1813
assert ! ( !session. exists( ) ) ;
1820
1814
Tmux :: with_command (
1821
1815
NewSession :: new ( )
@@ -1905,7 +1899,7 @@ mod tests {
1905
1899
let mut session = Session {
1906
1900
..Default :: default ( )
1907
1901
} ;
1908
- session. set_name ( "testextended" ) . unwrap ( ) ;
1902
+ session. set_name ( "testextended" ) ;
1909
1903
// Fail, we have no data in session.targets yet
1910
1904
assert ! ( session. setup_extended_session( ) . is_err( ) ) ;
1911
1905
0 commit comments