Skip to content

Commit

Permalink
feat(lsp): map go code errors that aren't template expressions to clo… (
Browse files Browse the repository at this point in the history
  • Loading branch information
joerdav authored Apr 22, 2024
1 parent 573a891 commit 210391f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions parser/v2/sourcemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ func (sm *SourceMap) TargetPositionFromSource(line, col uint32) (tgt Position, o
}

// SourcePositionFromTarget looks the source position using the target position.
// If a source exists on the line but not the col, the function will search backwards.
func (sm *SourceMap) SourcePositionFromTarget(line, col uint32) (src Position, ok bool) {
lm, ok := sm.TargetLinesToSource[line]
if !ok {
return
}
src, ok = lm[col]
return
for {
src, ok = lm[col]
if ok || col == 0 {
return
}
col--
}
}

0 comments on commit 210391f

Please sign in to comment.