@@ -61,6 +61,32 @@ export async function activate(context: vscode.ExtensionContext) {
61
61
if ( ! config . get < boolean > ( 'fortls.disabled' ) ) {
62
62
new FortlsClient ( loggingService , context ) . activate ( ) ;
63
63
}
64
+ // override VS Code's default implementation of the debug hover
65
+ // here we match Fortran derived types and scope them appropriately
66
+ // e.g. "val%a%b" with hovering over "a" will match "val%a"
67
+ context . subscriptions . push (
68
+ vscode . languages . registerEvaluatableExpressionProvider ( FortranDocumentSelector ( ) , {
69
+ provideEvaluatableExpression (
70
+ document : vscode . TextDocument ,
71
+ position : vscode . Position ,
72
+ token : vscode . CancellationToken
73
+ ) : vscode . ProviderResult < vscode . EvaluatableExpression > {
74
+ // Match the % characters in defined types
75
+ const DERIVED_TYPE_REGEX = / [ a - z ] [ \w % ] * / i;
76
+ // Get the word at the current position and the string matching
77
+ // the derived type REGEX. Use the start of the regex and end of word as range
78
+ const wordRange = document . getWordRangeAtPosition ( position ) ;
79
+ const derivedTypeRange = document . getWordRangeAtPosition ( position , DERIVED_TYPE_REGEX ) ;
80
+ if ( wordRange ) {
81
+ if ( derivedTypeRange ) {
82
+ return new vscode . EvaluatableExpression ( wordRange . with ( derivedTypeRange . start ) ) ;
83
+ }
84
+ return new vscode . EvaluatableExpression ( wordRange ) ;
85
+ }
86
+ return undefined ;
87
+ } ,
88
+ } )
89
+ ) ;
64
90
}
65
91
66
92
function detectDeprecatedOptions ( ) {
0 commit comments