Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Default rootPath to current directory when in a workspaceless instance #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/features/providers/linter/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class LintingProvider {
const workspaceFolder = vscode.workspace.workspaceFolders
? vscode.workspace.workspaceFolders[0].uri.fsPath
: undefined;
const rootPath = workspaceFolder ? Utilities.normalizePath(workspaceFolder) : undefined;
const rootPath = workspaceFolder ? Utilities.normalizePath(workspaceFolder) : Utilities.normalizePath(".");
const workingDirectory = workspacePath ?? Configuration.workingDirectory(rootPath);
const filePath = document && !document.isUntitled ? Utilities.normalizePath(document.fileName) : workingDirectory;
Comment on lines +128 to 130
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue might actually be the filePath should be using the document.fileName, but for some reason the document.isUntitled is true sometimes in workspaceless instances even though the file has a filename. I am going to update this to instead check document.fileName.

This change will be released in v3.1.2, let me know if there are still issues and I can look into it further.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an ok solution, my only concern is the --stdin-filename path becomes something like sqlfluff lint --format json --stdin-filename ../../../../../path/to/vscode/Untitled-1 -. By itself, this is fine as it will pick up the workspace's root .sqlfluff file but could have unintended side effects if any additional .sqlfluff files exist on that path.


Expand Down
Loading