Skip to content

Commit

Permalink
v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertOstermann committed Jul 27, 2023
1 parent 0c90d49 commit 1f38d6b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the "sqlfluff" extension will be documented in this file.

## [2.4.0] - 2023-07-26

- Fix bug with - `SQLFluff Format Selection` now can be placed in the context menu.

## [2.3.9] - 2023-07-26

- Update the `sqlfluff.format.languages` to accept objects containing formatting settings for the languages to address this [Feature Request](https:/sqlfluff/vscode-sqlfluff/issues/94)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-sqlfluff",
"displayName": "sqlfluff",
"version": "2.3.9",
"version": "2.4.0",
"description": "A linter and auto-formatter for SQLfluff, a popular linting tool for SQL and dbt.",
"publisher": "dorzey",
"icon": "images/icon.png",
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const activate = (context: vscode.ExtensionContext) => {
context.subscriptions.push(hoverProvider);
});

vscode.commands.executeCommand("setContext", "sqlfluff.formatLanguages", formatSelectors)
const contextMenuItems = Configuration.formatLanguagesContextMenuItems();
vscode.commands.executeCommand("setContext", "sqlfluff.formatLanguages", contextMenuItems)

context.subscriptions.push(vscode.commands.registerCommand(EXCLUDE_RULE, ExcludeRules.toggleRule));
context.subscriptions.push(vscode.commands.registerCommand(EXCLUDE_RULE_WORKSPACE, ExcludeRules.toggleRuleWorkspace));
Expand Down
16 changes: 16 additions & 0 deletions src/features/helper/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,22 @@ export default class Configuration {
return languages;
}

public static formatLanguagesContextMenuItems(): string[] {
const languageSettings: (FormatLanguageSettings | string)[] | undefined = vscode.workspace
.getConfiguration("sqlfluff.format")
.get("languages");


const languages: string[] = [];
languageSettings?.forEach((languageSetting: FormatLanguageSettings | string) => {
if (typeof languageSetting !== "string" && languageSetting.contextMenuFormatOptions) {
languages.push(languageSetting.language);
}
})

return languages;
}

public static formatLanguageSetting(languageId: string): FormatLanguageSettings | undefined {
const languageSettings: (FormatLanguageSettings | string)[] | undefined = vscode.workspace
.getConfiguration("sqlfluff.format")
Expand Down

0 comments on commit 1f38d6b

Please sign in to comment.