Skip to content

Commit

Permalink
Merge pull request #2167 from alixander/no-fs
Browse files Browse the repository at this point in the history
no need to pass fs
  • Loading branch information
alixander authored Oct 17, 2024
2 parents f81d839 + 6c04743 commit 4fd0af8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions d2lsp/d2lsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ func GetRefs(path string, fs map[string]string, boardPath []string, key string)
return refs, nil
}

func GetImportRanges(path string, fs map[string]string, importPath string) (ranges []d2ast.Range, _ error) {
if _, ok := fs[path]; !ok {
return nil, fmt.Errorf(`"%s" not found`, path)
}
r := strings.NewReader(fs[path])
func GetImportRanges(path, file string, importPath string) (ranges []d2ast.Range, _ error) {
r := strings.NewReader(file)
ast, err := d2parser.Parse(path, r, nil)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions d2lsp/d2lsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ okay
des
`,
}
ranges, err := d2lsp.GetImportRanges("yes/index.d2", fs, "fast/ok.d2")
ranges, err := d2lsp.GetImportRanges("yes/index.d2", fs["yes/index.d2"], "fast/ok.d2")
assert.Success(t, err)
assert.Equal(t, 1, len(ranges))
assert.Equal(t, 1, ranges[0].Start.Line)

ranges, err = d2lsp.GetImportRanges("yes/index.d2", fs, "yes/pok.d2")
ranges, err = d2lsp.GetImportRanges("yes/index.d2", fs["yes/index.d2"], "yes/pok.d2")
assert.Success(t, err)
assert.Equal(t, 1, len(ranges))
assert.Equal(t, 4, ranges[0].Start.Line)
Expand Down

0 comments on commit 4fd0af8

Please sign in to comment.