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

Prevent "Specified path does not exist" error for empty untitled files #149

Merged

Conversation

jackfrey13
Copy link
Contributor

I use the vscode-sqlfluff extension with Azure Data Studio. I recently moved to a new computer and after getting ADS set back up, I noticed that the extension was throwing an error saying "User Error: Specified path does not exist. Check it/they exist(s): ." whenver I open a new file (via File > New Query or right clicking on a database and clicking New Query).

image

The error only happens when the file first opens and is empty. As soon as the file has text/sql in it, the extension works and lints the file as expected. Nothing changed with my local extension config when I moved my files to the new computer (I did download the latest version of SqlFluff so it's possible I have newer version of that, but I can't remember what version I had installed on my old PC), so I'm not sure what would cause this error to start occuring all of the sudden.

Since it's not really necessary to lint an empty file, I thought an easy fix would be to skip linting when you're in an untitled file that's empty. I tested locally with this change and everything worked as expected. I also had a coworker who was experiencing the error do some testing and they reported no longer seeing the error with this change.

@jackfrey13
Copy link
Contributor Author

Also, not 100% sure if this matters, but right now the code for firing triggerLint with the onDidOpenTextDocument event is

vscode.workspace.onDidOpenTextDocument(this.triggerLint, this, subscriptions);

Technically, when a new document is open, it is the current document so this might make more sense:

vscode.workspace.onDidOpenTextDocument(
    (textDocument) => {
        this.triggerLint(textDocument, true);
    },
    null,
    subscriptions,
);

Would be happy to add that to the PR if you think it would be a good change!

@jackfrey13
Copy link
Contributor Author

Added a similar fix to prevent a "Specified path does not exist" error when formatting an empty, unsaved document with the editor.action.formatDocument command.

image

@RobertOstermann RobertOstermann merged commit c06d99d into sqlfluff:master Jul 19, 2024
4 checks passed
@RobertOstermann
Copy link
Contributor

Thanks for the PR! This will be released in v3.1.2

@jackfrey13 jackfrey13 deleted the ads-untitle-file-error-fix branch July 19, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants