@@ -137,7 +137,7 @@ export class DebugHoverWidget implements IContentWidget {
137137 return this . domNode ;
138138 }
139139
140- showAt ( range : Range , focus : boolean ) : Promise < void > {
140+ async showAt ( range : Range , focus : boolean ) : Promise < void > {
141141 const pos = range . getStartPosition ( ) ;
142142
143143 const session = this . debugService . getViewModel ( ) . focusedSession ;
@@ -153,63 +153,64 @@ export class DebugHoverWidget implements IContentWidget {
153153 return Promise . resolve ( this . hide ( ) ) ;
154154 }
155155
156- let promise : Promise < IExpression | undefined > ;
156+ let expression ;
157157 if ( session . capabilities . supportsEvaluateForHovers ) {
158- const result = new Expression ( matchingExpression ) ;
159- promise = result . evaluate ( session , this . debugService . getViewModel ( ) . focusedStackFrame , 'hover' ) . then ( ( ) => result ) ;
158+ expression = new Expression ( matchingExpression ) ;
159+ await expression . evaluate ( session , this . debugService . getViewModel ( ) . focusedStackFrame , 'hover' ) ;
160160 } else {
161- promise = this . findExpressionInStackFrame ( coalesce ( matchingExpression . split ( '.' ) . map ( word => word . trim ( ) ) ) ) ;
161+ expression = await this . findExpressionInStackFrame ( coalesce ( matchingExpression . split ( '.' ) . map ( word => word . trim ( ) ) ) ) ;
162162 }
163163
164- return promise . then ( expression => {
165- if ( ! expression || ( expression instanceof Expression && ! expression . available ) ) {
166- this . hide ( ) ;
167- return undefined ;
168- }
164+ if ( ! expression || ( expression instanceof Expression && ! expression . available ) ) {
165+ this . hide ( ) ;
166+ return undefined ;
167+ }
169168
170- this . highlightDecorations = this . editor . deltaDecorations ( this . highlightDecorations , [ {
171- range : new Range ( pos . lineNumber , start , pos . lineNumber , start + matchingExpression . length ) ,
172- options : DebugHoverWidget . _HOVER_HIGHLIGHT_DECORATION_OPTIONS
173- } ] ) ;
169+ this . highlightDecorations = this . editor . deltaDecorations ( this . highlightDecorations , [ {
170+ range : new Range ( pos . lineNumber , start , pos . lineNumber , start + matchingExpression . length ) ,
171+ options : DebugHoverWidget . _HOVER_HIGHLIGHT_DECORATION_OPTIONS
172+ } ] ) ;
174173
175- return this . doShow ( pos , expression , focus ) ;
176- } ) ;
174+ return this . doShow ( pos , expression , focus ) ;
177175 }
178176
179177 private static _HOVER_HIGHLIGHT_DECORATION_OPTIONS = ModelDecorationOptions . register ( {
180178 className : 'hoverHighlight'
181179 } ) ;
182180
183- private doFindExpression ( container : IExpressionContainer , namesToFind : string [ ] ) : Promise < IExpression | null > {
181+ private async doFindExpression ( container : IExpressionContainer , namesToFind : string [ ] ) : Promise < IExpression | null > {
184182 if ( ! container ) {
185183 return Promise . resolve ( null ) ;
186184 }
187185
188- return container . getChildren ( ) . then ( children => {
189- // look for our variable in the list. First find the parents of the hovered variable if there are any.
190- const filtered = children . filter ( v => namesToFind [ 0 ] === v . name ) ;
191- if ( filtered . length !== 1 ) {
192- return null ;
193- }
186+ const children = await container . getChildren ( ) ;
187+ // look for our variable in the list. First find the parents of the hovered variable if there are any.
188+ const filtered = children . filter ( v => namesToFind [ 0 ] === v . name ) ;
189+ if ( filtered . length !== 1 ) {
190+ return null ;
191+ }
194192
195- if ( namesToFind . length === 1 ) {
196- return filtered [ 0 ] ;
197- } else {
198- return this . doFindExpression ( filtered [ 0 ] , namesToFind . slice ( 1 ) ) ;
199- }
200- } ) ;
193+ if ( namesToFind . length === 1 ) {
194+ return filtered [ 0 ] ;
195+ } else {
196+ return this . doFindExpression ( filtered [ 0 ] , namesToFind . slice ( 1 ) ) ;
197+ }
201198 }
202199
203- private findExpressionInStackFrame ( namesToFind : string [ ] ) : Promise < IExpression | undefined > {
204- return this . debugService . getViewModel ( ) . focusedStackFrame ! . getScopes ( )
205- . then ( scopes => scopes . filter ( s => ! s . expensive ) )
206- . then ( scopes => Promise . all ( scopes . map ( scope => this . doFindExpression ( scope , namesToFind ) ) ) )
207- . then ( coalesce )
208- // only show if all expressions found have the same value
209- . then ( expressions => ( expressions . length > 0 && expressions . every ( e => e . value === expressions [ 0 ] . value ) ) ? expressions [ 0 ] : undefined ) ;
200+ private async findExpressionInStackFrame ( namesToFind : string [ ] ) : Promise < IExpression | undefined > {
201+ const focusedStackFrame = this . debugService . getViewModel ( ) . focusedStackFrame ;
202+ if ( ! focusedStackFrame ) {
203+ return undefined ;
204+ }
205+
206+ const scopes = await focusedStackFrame . getScopes ( ) ;
207+ const nonExpensive = scopes . filter ( s => ! s . expensive ) ;
208+ const expressions = coalesce ( await Promise . all ( nonExpensive . map ( scope => this . doFindExpression ( scope , namesToFind ) ) ) ) ;
209+ // only show if all expressions found have the same value
210+ return expressions . length > 0 && expressions . every ( e => e . value === expressions [ 0 ] . value ) ? expressions [ 0 ] : undefined ;
210211 }
211212
212- private doShow ( position : Position , expression : IExpression , focus : boolean , forceValueHover = false ) : Promise < void > {
213+ private async doShow ( position : Position , expression : IExpression , focus : boolean , forceValueHover = false ) : Promise < void > {
213214 if ( ! this . domNode ) {
214215 this . create ( ) ;
215216 }
@@ -239,20 +240,19 @@ export class DebugHoverWidget implements IContentWidget {
239240 this . valueContainer . hidden = true ;
240241 this . complexValueContainer . hidden = false ;
241242
242- return this . tree . setInput ( expression ) . then ( ( ) => {
243- this . complexValueTitle . textContent = replaceWhitespace ( expression . value ) ;
244- this . complexValueTitle . title = expression . value ;
245- this . layoutTreeAndContainer ( ) ;
246- this . editor . layoutContentWidget ( this ) ;
247- this . scrollbar . scanDomNode ( ) ;
248- this . tree . scrollTop = 0 ;
249- this . tree . scrollLeft = 0 ;
243+ await this . tree . setInput ( expression ) ;
244+ this . complexValueTitle . textContent = replaceWhitespace ( expression . value ) ;
245+ this . complexValueTitle . title = expression . value ;
246+ this . layoutTreeAndContainer ( ) ;
247+ this . editor . layoutContentWidget ( this ) ;
248+ this . scrollbar . scanDomNode ( ) ;
249+ this . tree . scrollTop = 0 ;
250+ this . tree . scrollLeft = 0 ;
250251
251- if ( focus ) {
252- this . editor . render ( ) ;
253- this . tree . domFocus ( ) ;
254- }
255- } ) ;
252+ if ( focus ) {
253+ this . editor . render ( ) ;
254+ this . tree . domFocus ( ) ;
255+ }
256256 }
257257
258258 private layoutTreeAndContainer ( ) : void {
0 commit comments