This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +46
-9
lines changed Expand file tree Collapse file tree 3 files changed +46
-9
lines changed Original file line number Diff line number Diff line change @@ -259,15 +259,16 @@ impl<'a> FmtVisitor<'a> {
259
259
status. last_wspace = None ;
260
260
status. line_start = offset + subslice. len ( ) ;
261
261
262
- if let Some ( '/' ) = subslice. chars ( ) . nth ( 1 ) {
263
- // Only add a newline if the last line is a line comment
264
- if !subslice. trim_end ( ) . ends_with ( "*/" ) {
265
- self . push_str ( "\n " ) ;
266
- }
267
- } else if status. line_start <= snippet. len ( ) {
268
- // For other comments add a newline if there isn't one at the end already
262
+ // Add a newline:
263
+ // - if there isn't one already
264
+ // - otherwise, only if the last line is a line comment
265
+ if status. line_start <= snippet. len ( ) {
269
266
match snippet[ status. line_start ..] . chars ( ) . next ( ) {
270
- Some ( '\n' ) | Some ( '\r' ) => ( ) ,
267
+ Some ( '\n' ) | Some ( '\r' ) => {
268
+ if !subslice. trim_end ( ) . ends_with ( "*/" ) {
269
+ self . push_str ( "\n " ) ;
270
+ }
271
+ }
271
272
_ => self . push_str ( "\n " ) ,
272
273
}
273
274
}
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
236
236
}
237
237
}
238
238
239
- let unindent_comment = ( self . is_if_else_block && !b. stmts . is_empty ( ) ) && {
239
+ let unindent_comment = self . is_if_else_block && !b. stmts . is_empty ( ) && {
240
240
let end_pos = source ! ( self , b. span) . hi ( ) - brace_compensation - remove_len;
241
241
let snippet = self . snippet ( mk_sp ( self . last_pos , end_pos) ) ;
242
242
snippet. contains ( "//" ) || snippet. contains ( "/*" )
Original file line number Diff line number Diff line change
1
+ pub fn get_array_index_from_id ( _cx : * mut JSContext , id : HandleId ) -> Option < u32 > {
2
+ let raw_id = id. into ( ) ;
3
+ unsafe {
4
+ if RUST_JSID_IS_INT ( raw_id) {
5
+ return Some ( RUST_JSID_TO_INT ( raw_id) as u32 ) ;
6
+ }
7
+ None
8
+ }
9
+ // if id is length atom, -1, otherwise
10
+ /*return if JSID_IS_ATOM(id) {
11
+ let atom = JSID_TO_ATOM(id);
12
+ //let s = *GetAtomChars(id);
13
+ if s > 'a' && s < 'z' {
14
+ return -1;
15
+ }
16
+
17
+ let i = 0;
18
+ let str = AtomToLinearString(JSID_TO_ATOM(id));
19
+ return if StringIsArray(str, &mut i) != 0 { i } else { -1 }
20
+ } else {
21
+ IdToInt32(cx, id);
22
+ }*/
23
+ }
24
+
25
+ impl Foo {
26
+ fn bar ( ) -> usize {
27
+ 42
28
+ /* a block comment */
29
+ }
30
+
31
+ fn baz ( ) -> usize {
32
+ 42
33
+ // this is a line
34
+ /* a block comment */
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments