Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

lsp: ignore after rename if not Rego #1340

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,10 @@ func (l *LanguageServer) handleWorkspaceDidRenameFiles(
l.logf(log.LevelMessage, "failed to send diagnostic: %s", err)
}

if l.ignoreURI(renameOp.NewURI) {
continue
}

l.cache.SetFileContents(renameOp.NewURI, content)

job := lintFileJob{
Expand Down Expand Up @@ -2556,11 +2560,6 @@ func (l *LanguageServer) loadWorkspaceContents(ctx context.Context, newOnly bool
changedOrNewURIs := make([]string, 0)

if err := rio.WalkFiles(workspaceRootPath, func(path string) error {
// TODO(charlieegan3): make this configurable for things like .rq etc?
if !strings.HasSuffix(path, ".rego") {
return nil
}

fileURI := uri.FromPath(l.clientIdentifier, path)

if l.ignoreURI(fileURI) {
Expand Down Expand Up @@ -2726,6 +2725,11 @@ func (l *LanguageServer) getFilteredModules() (map[string]*ast.Module, error) {
}

func (l *LanguageServer) ignoreURI(fileURI string) bool {
// TODO(charlieegan3): make this configurable for things like .rq etc?
if !strings.HasSuffix(fileURI, ".rego") {
return true
}

cfg := l.getLoadedConfig()
if cfg == nil {
return false
Expand Down
Loading