Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Fix microsoft/vscode#31469 - No hover on variables in async functions
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jul 30, 2017
1 parent fdbdb93 commit f82d017
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/transformers/baseSourceMapTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,24 @@ export class BaseSourceMapTransformer {
return;
}

const mappedStart = this._sourceMaps.mapToAuthored(pathToGenerated, scope.line, scope.column);
let mappedStart = this._sourceMaps.mapToAuthored(pathToGenerated, scope.line, scope.column);
let shiftedScopeStartForward = false;

// If the scope is an async function, then the function declaration line may be missing a source mapping.
// So if we failed, try to get the next line.
if (!mappedStart) {
mappedStart = this._sourceMaps.mapToAuthored(pathToGenerated, scope.line + 1, scope.column);
shiftedScopeStartForward = true;
}

if (mappedStart) {
// Only apply changes if both mappings are found
const mappedEnd = this._sourceMaps.mapToAuthored(pathToGenerated, scope.endLine, scope.endColumn);
if (mappedEnd) {
scope.line = mappedStart.line;
if (shiftedScopeStartForward) {
scope.line--;
}
scope.column = mappedStart.column;

scope.endLine = mappedEnd.line;
Expand Down

0 comments on commit f82d017

Please sign in to comment.