@@ -157,13 +157,21 @@ async fn handle(
157
157
labels. push ( Label { name : label_to_add } ) ;
158
158
let github_req = issue. set_labels ( & ctx. github , labels) ;
159
159
160
- let mut zulip_topic = format ! ( " {}" , issue. zulip_topic_reference( ) ) ;
161
- // We prepend the issue title, truncating such that the overall length does
162
- // not exceed 60 characters (a Zulip limitation).
163
- zulip_topic. insert_str (
164
- 0 ,
165
- & issue. title [ ..std:: cmp:: min ( issue. title . len ( ) , 60 - zulip_topic. len ( ) ) ] ,
166
- ) ;
160
+ // Concatenate the issue title and the topic reference, truncating such that
161
+ // the overall length does not exceed 60 characters (a Zulip limitation).
162
+ let topic_ref = issue. zulip_topic_reference ( ) ;
163
+ // Skip chars until the last characters that can be written:
164
+ // Maximum 60, minus the reference, minus the elipsis and the space
165
+ let mut chars = issue
166
+ . title
167
+ . char_indices ( )
168
+ . skip ( 60 - topic_ref. chars ( ) . count ( ) - 2 ) ;
169
+ let zulip_topic = match chars. next ( ) {
170
+ Some ( ( len, _) ) if chars. next ( ) . is_some ( ) => {
171
+ format ! ( "{}… {}" , & issue. title[ ..len] , topic_ref)
172
+ }
173
+ _ => format ! ( "{} {}" , issue. title, topic_ref) ,
174
+ } ;
167
175
168
176
let zulip_req = crate :: zulip:: MessageApiRequest {
169
177
recipient : crate :: zulip:: Recipient :: Stream {
0 commit comments