Skip to content

Commit 72690de

Browse files
committed
improved import completion
1 parent cd5c67c commit 72690de

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/DDP-Projekt/DDPLS
33
go 1.22.2
44

55
require (
6-
github.com/DDP-Projekt/Kompilierer v0.4.0-alpha.0.20240727075930-9369ebd7971e
6+
github.com/DDP-Projekt/Kompilierer v0.4.0-alpha.0.20240810130912-13f2cd903dcb
77
github.com/tliron/commonlog v0.2.8
88
github.com/tliron/glsp v0.2.2-0.20240309182338-ab78d718ad7d
99
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/DDP-Projekt/Kompilierer v0.4.0-alpha.0.20240727075930-9369ebd7971e h1:7ljq6q/rKTPJZ4um9KNfGeULStZpiXw88zVf+IXVT20=
2-
github.com/DDP-Projekt/Kompilierer v0.4.0-alpha.0.20240727075930-9369ebd7971e/go.mod h1:vp0zj11n6rP/B+o7BIXmUhhjrpZNO1c7/pf+VPSHIzM=
1+
github.com/DDP-Projekt/Kompilierer v0.4.0-alpha.0.20240810130912-13f2cd903dcb h1:CZP0ZVHQXduIWCX9UVNOg9DvDTUBDPGwuPBCxOWHkEQ=
2+
github.com/DDP-Projekt/Kompilierer v0.4.0-alpha.0.20240810130912-13f2cd903dcb/go.mod h1:vp0zj11n6rP/B+o7BIXmUhhjrpZNO1c7/pf+VPSHIzM=
33
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
44
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
55
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

handlers/completion.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,14 @@ func (vis *importVisitor) VisitImportStmt(imprt *ast.ImportStmt) ast.VisitResult
365365
vis.items = make([]protocol.CompletionItem, 0, len(dudenPaths))
366366

367367
incompletePath := filepath.Dir(ast.TrimStringLit(&imprt.FileName))
368+
hasDudenPrefix := strings.HasPrefix(incompletePath, "Duden")
368369

369-
if incompletePath == "." {
370+
if incompletePath == "." || hasDudenPrefix {
370371
addDudenPaths(vis.items)
371372
}
372373

373374
searchPath := filepath.Join(filepath.Dir(vis.modPath), incompletePath)
374-
if vis.isSlashCompletion && incompletePath == "Duden" {
375+
if hasDudenPrefix {
375376
searchPath = ddppath.Duden
376377
}
377378

@@ -392,6 +393,7 @@ func (vis *importVisitor) VisitImportStmt(imprt *ast.ImportStmt) ast.VisitResult
392393
path = incompletePath + "/" + path
393394
}
394395
finalPath := strings.TrimPrefix(path, "./")
396+
finalPath = strings.TrimPrefix(finalPath, ast.TrimStringLit(&imprt.FileName))
395397
vis.items = append(vis.items, pathToCompletionItem(finalPath))
396398
}
397399
}

0 commit comments

Comments
 (0)