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

Commit

Permalink
Fix #112 - Switch sourcemap biases for authoredPositionFor
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jun 10, 2017
1 parent d153541 commit 4bb4a8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sourceMaps/sourceMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ export class SourceMap {
const lookupArgs = {
line,
column,
bias: (<any>SourceMapConsumer).LEAST_UPPER_BOUND
bias: (<any>SourceMapConsumer).GREATEST_LOWER_BOUND
};

let position = this._smc.originalPositionFor(lookupArgs);
if (!position.source) {
// If it can't find a match, it returns a mapping with null props. Try looking the other direction.
lookupArgs.bias = (<any>SourceMapConsumer).GREATEST_LOWER_BOUND;
lookupArgs.bias = (<any>SourceMapConsumer).LEAST_UPPER_BOUND;
position = this._smc.originalPositionFor(lookupArgs);
}

Expand Down
4 changes: 2 additions & 2 deletions test/sourceMaps/sourceMap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ suite('SourceMap', () => {
getExpectedResult(/*line=*/11, /*column=*/8));

assert.deepEqual(
sm.authoredPositionFor(/*line=*/9, /*column=*/9),
sm.authoredPositionFor(/*line=*/9, /*column=*/12),
getExpectedResult(/*line=*/11, /*column=*/12));
});

Expand All @@ -157,7 +157,7 @@ suite('SourceMap', () => {

assert.deepEqual(
sm.authoredPositionFor(/*line=*/5, /*column=*/17),
getExpectedResult(/*line=*/4, /*column=*/25));
getExpectedResult(/*line=*/4, /*column=*/14));
});

test('first line of file', () => {
Expand Down

0 comments on commit 4bb4a8c

Please sign in to comment.