@@ -141,29 +141,37 @@ export function convert(source, ast) {
141
141
} ;
142
142
143
143
if ( node . pending ) {
144
- const first = /** @type { import('#compiler').BaseNode } */ ( node . pending . nodes . at ( 0 ) ) ;
145
- const last = /** @type { import('#compiler').BaseNode } */ ( node . pending . nodes . at ( - 1 ) ) ;
144
+ const first = node . pending . nodes . at ( 0 ) ;
145
+ const last = node . pending . nodes . at ( - 1 ) ;
146
146
147
- pendingblock . start = first . start ;
148
- pendingblock . end = last . end ;
147
+ pendingblock . start = first ? .start ?? source . indexOf ( '}' , node . expression . end ) + 1 ;
148
+ pendingblock . end = last ? .end ?? pendingblock . start ;
149
149
pendingblock . skip = false ;
150
150
}
151
151
152
152
if ( node . then ) {
153
- const first = /** @type { import('#compiler').BaseNode } */ ( node . then . nodes . at ( 0 ) ) ;
154
- const last = /** @type { import('#compiler').BaseNode } */ ( node . then . nodes . at ( - 1 ) ) ;
153
+ const first = node . then . nodes . at ( 0 ) ;
154
+ const last = node . then . nodes . at ( - 1 ) ;
155
155
156
- thenblock . start = pendingblock . end ?? first . start ;
157
- thenblock . end = last . end ;
156
+ thenblock . start =
157
+ pendingblock . end ?? first ?. start ?? source . indexOf ( '}' , node . expression . end ) + 1 ;
158
+ thenblock . end =
159
+ last ?. end ?? source . lastIndexOf ( '}' , pendingblock . end ?? node . expression . end ) + 1 ;
158
160
thenblock . skip = false ;
159
161
}
160
162
161
163
if ( node . catch ) {
162
- const first = /** @type {import('#compiler').BaseNode } */ ( node . catch . nodes . at ( 0 ) ) ;
163
- const last = /** @type {import('#compiler').BaseNode } */ ( node . catch . nodes . at ( - 1 ) ) ;
164
-
165
- catchblock . start = thenblock . end ?? pendingblock . end ?? first . start ;
166
- catchblock . end = last . end ;
164
+ const first = node . catch . nodes . at ( 0 ) ;
165
+ const last = node . catch . nodes . at ( - 1 ) ;
166
+
167
+ catchblock . start =
168
+ thenblock . end ??
169
+ pendingblock . end ??
170
+ first ?. start ??
171
+ source . indexOf ( '}' , node . expression . end ) + 1 ;
172
+ catchblock . end =
173
+ last ?. end ??
174
+ source . lastIndexOf ( '}' , thenblock . end ?? pendingblock . end ?? node . expression . end ) + 1 ;
167
175
catchblock . skip = false ;
168
176
}
169
177
0 commit comments