Skip to content

Commit

Permalink
Prioritize exact location matches when navigating
Browse files Browse the repository at this point in the history
  • Loading branch information
Discookie committed Feb 11, 2022
1 parent 0a3643b commit 4a40aea
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/editor/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export class NavigationHandler {
const entry = ExtensionApi.diagnostics.selectedEntry.diagnostic;
const reprPath = entry.bug_path_events;

// The cursor is on the bug's original jump location
let isExactPosition = false;
let foundIdx = null;

for (const [idx, path] of reprPath.entries()) {
Expand All @@ -103,6 +105,7 @@ export class NavigationHandler {

if (cursor.isEqual(new Position(path.line-1, path.column-1))) {
foundIdx = idx;
isExactPosition = true;

if (which === 'first') {
break;
Expand All @@ -111,8 +114,8 @@ export class NavigationHandler {
continue;
}

// Check inside the ranges
if (!path.range) {
// Check inside the ranges, but only if no exact match was found
if (!path.range || isExactPosition) {
continue;
}

Expand Down

0 comments on commit 4a40aea

Please sign in to comment.