feat(editor): configure parameter examples in function completion
This commit is contained in:
1 parent
37b1c061d5
commit
c7c54c8239
24 files changed
+174
-19
No files matched your search
@@ -688,6 +688,7 @@ const tableCompletionSchemaQualificationDescription = computed(() => {
|
||||
});
|
||||
const editInsertSpaceAfterCompletion = ref(settingsStore.editorSettings.insertSpaceAfterCompletion);
|
||||
const editSqlServerSpaceConfirmsCompletion = ref(settingsStore.editorSettings.sqlServerSpaceConfirmsCompletion);
|
||||
const editFunctionCompletionIncludeParams = ref(settingsStore.editorSettings.functionCompletionIncludeParams);
|
||||
const showSqlServerSpaceConfirmsCompletion = computed(() => hasSqlServerConnection.value || settingsStore.editorSettings.sqlServerSpaceConfirmsCompletion || editSqlServerSpaceConfirmsCompletion.value);
|
||||
const editSortCompletionColumnsAlphabetically = ref(settingsStore.editorSettings.sortCompletionColumnsAlphabetically);
|
||||
const editSelectFirstCompletionOnOpen = ref(settingsStore.editorSettings.selectFirstCompletionOnOpen);
|
||||
@@ -1075,6 +1076,7 @@ function currentEditorSettingsDraft(): EditorSettingsDraft {
|
||||
tableCompletionSchemaQualification: editTableCompletionSchemaQualification.value,
|
||||
insertSpaceAfterCompletion: editInsertSpaceAfterCompletion.value,
|
||||
sqlServerSpaceConfirmsCompletion: editSqlServerSpaceConfirmsCompletion.value,
|
||||
functionCompletionIncludeParams: editFunctionCompletionIncludeParams.value,
|
||||
sortCompletionColumnsAlphabetically: editSortCompletionColumnsAlphabetically.value,
|
||||
selectFirstCompletionOnOpen: editSelectFirstCompletionOnOpen.value,
|
||||
completionTriggerMode: editCompletionTriggerMode.value,
|
||||
@@ -1752,6 +1754,7 @@ function syncEditorSettingsDraftFromStore() {
|
||||
editTableCompletionSchemaQualification.value = settingsStore.editorSettings.tableCompletionSchemaQualification;
|
||||
editInsertSpaceAfterCompletion.value = settingsStore.editorSettings.insertSpaceAfterCompletion;
|
||||
editSqlServerSpaceConfirmsCompletion.value = settingsStore.editorSettings.sqlServerSpaceConfirmsCompletion;
|
||||
editFunctionCompletionIncludeParams.value = settingsStore.editorSettings.functionCompletionIncludeParams;
|
||||
editSortCompletionColumnsAlphabetically.value = settingsStore.editorSettings.sortCompletionColumnsAlphabetically;
|
||||
editSelectFirstCompletionOnOpen.value = settingsStore.editorSettings.selectFirstCompletionOnOpen;
|
||||
editCompletionTriggerMode.value = settingsStore.editorSettings.completionTriggerMode;
|
||||
@@ -1908,6 +1911,7 @@ const editorSettingsDraftRefs: EditorSettingsDraftRefMap = {
|
||||
tableCompletionSchemaQualification: editTableCompletionSchemaQualification,
|
||||
insertSpaceAfterCompletion: editInsertSpaceAfterCompletion,
|
||||
sqlServerSpaceConfirmsCompletion: editSqlServerSpaceConfirmsCompletion,
|
||||
functionCompletionIncludeParams: editFunctionCompletionIncludeParams,
|
||||
sortCompletionColumnsAlphabetically: editSortCompletionColumnsAlphabetically,
|
||||
selectFirstCompletionOnOpen: editSelectFirstCompletionOnOpen,
|
||||
wordWrap: editWordWrap,
|
||||
@@ -2439,6 +2443,7 @@ function resetDefaultsForTab(tab: SettingsCategory) {
|
||||
editTableCompletionSchemaQualification.value = DEFAULT_EDITOR_SETTINGS.tableCompletionSchemaQualification;
|
||||
editInsertSpaceAfterCompletion.value = DEFAULT_EDITOR_SETTINGS.insertSpaceAfterCompletion;
|
||||
editSqlServerSpaceConfirmsCompletion.value = DEFAULT_EDITOR_SETTINGS.sqlServerSpaceConfirmsCompletion;
|
||||
editFunctionCompletionIncludeParams.value = DEFAULT_EDITOR_SETTINGS.functionCompletionIncludeParams;
|
||||
editSortCompletionColumnsAlphabetically.value = DEFAULT_EDITOR_SETTINGS.sortCompletionColumnsAlphabetically;
|
||||
editSelectFirstCompletionOnOpen.value = DEFAULT_EDITOR_SETTINGS.selectFirstCompletionOnOpen;
|
||||
editCompletionTriggerMode.value = DEFAULT_EDITOR_SETTINGS.completionTriggerMode;
|
||||
@@ -2615,6 +2620,7 @@ function resetAllDefaults() {
|
||||
editTableCompletionSchemaQualification.value = DEFAULT_EDITOR_SETTINGS.tableCompletionSchemaQualification;
|
||||
editInsertSpaceAfterCompletion.value = DEFAULT_EDITOR_SETTINGS.insertSpaceAfterCompletion;
|
||||
editSqlServerSpaceConfirmsCompletion.value = DEFAULT_EDITOR_SETTINGS.sqlServerSpaceConfirmsCompletion;
|
||||
editFunctionCompletionIncludeParams.value = DEFAULT_EDITOR_SETTINGS.functionCompletionIncludeParams;
|
||||
editSortCompletionColumnsAlphabetically.value = DEFAULT_EDITOR_SETTINGS.sortCompletionColumnsAlphabetically;
|
||||
editSelectFirstCompletionOnOpen.value = DEFAULT_EDITOR_SETTINGS.selectFirstCompletionOnOpen;
|
||||
editWordWrap.value = DEFAULT_EDITOR_SETTINGS.wordWrap;
|
||||
@@ -6889,6 +6895,16 @@ onUnmounted(() => {
|
||||
<Switch id="editor-sqlserver-space-confirms-completion" v-model="editSqlServerSpaceConfirmsCompletion" class="mt-0.5" />
|
||||
</div>
|
||||
|
||||
<div class="settings-item flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
|
||||
<div class="space-y-1">
|
||||
<Label for="editor-function-completion-include-params">{{ t("settings.functionCompletionIncludeParams") }}</Label>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t("settings.functionCompletionIncludeParamsDescription") }}
|
||||
</p>
|
||||
</div>
|
||||
<Switch id="editor-function-completion-include-params" v-model="editFunctionCompletionIncludeParams" class="mt-0.5" />
|
||||
</div>
|
||||
|
||||
<div class="settings-item flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
|
||||
<div class="space-y-1">
|
||||
<Label for="editor-sort-completion-columns-alphabetically">{{ t("settings.sortCompletionColumnsAlphabetically") }}</Label>
|
||||
|
||||
@@ -846,6 +846,7 @@ export function useQueryEditorCompletion(options: QueryEditorCompletionOptions)
|
||||
autoAliasTables: settingsStore.editorSettings.autoAliasTables,
|
||||
tableCompletionSchemaQualification: settingsStore.editorSettings.tableCompletionSchemaQualification,
|
||||
quoteIdentifiers: settingsStore.editorSettings.generateSqlQuoteIdentifiers,
|
||||
functionCompletionIncludeParams: settingsStore.editorSettings.functionCompletionIncludeParams,
|
||||
});
|
||||
return buildSqlCompletionResult(items, completionContext, fullDoc, position);
|
||||
}
|
||||
@@ -909,6 +910,7 @@ export function useQueryEditorCompletion(options: QueryEditorCompletionOptions)
|
||||
autoAliasTables: settingsStore.editorSettings.autoAliasTables,
|
||||
tableCompletionSchemaQualification: settingsStore.editorSettings.tableCompletionSchemaQualification,
|
||||
quoteIdentifiers: settingsStore.editorSettings.generateSqlQuoteIdentifiers,
|
||||
functionCompletionIncludeParams: settingsStore.editorSettings.functionCompletionIncludeParams,
|
||||
});
|
||||
return buildSqlCompletionResult(items, completionContext, fullDoc, position);
|
||||
}
|
||||
@@ -1213,6 +1215,7 @@ export function useQueryEditorCompletion(options: QueryEditorCompletionOptions)
|
||||
autoAliasTables: settingsStore.editorSettings.autoAliasTables,
|
||||
tableCompletionSchemaQualification: settingsStore.editorSettings.tableCompletionSchemaQualification,
|
||||
quoteIdentifiers: settingsStore.editorSettings.generateSqlQuoteIdentifiers,
|
||||
functionCompletionIncludeParams: settingsStore.editorSettings.functionCompletionIncludeParams,
|
||||
});
|
||||
|
||||
return buildSqlCompletionResult(items, completionContext, fullDoc, position);
|
||||
@@ -1677,6 +1680,7 @@ export function useQueryEditorCompletion(options: QueryEditorCompletionOptions)
|
||||
autoAliasTables: settingsStore.editorSettings.autoAliasTables,
|
||||
tableCompletionSchemaQualification: settingsStore.editorSettings.tableCompletionSchemaQualification,
|
||||
quoteIdentifiers: settingsStore.editorSettings.generateSqlQuoteIdentifiers,
|
||||
functionCompletionIncludeParams: settingsStore.editorSettings.functionCompletionIncludeParams,
|
||||
});
|
||||
|
||||
return buildSqlCompletionResult(items, completionContext, fullDoc, position);
|
||||
|
||||
@@ -7665,6 +7665,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "FROM və ya JOIN daxilində cədvəl tamamlaması seçilərkən order_items AS oi kimi yaradılmış ləqəb daxil et.",
|
||||
sqlServerSpaceConfirmsCompletion: "Boşluqla tamamlamanı təsdiqlə (SQL Server üslubu)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "Tamamlama siyahısı açıqkən boşluq düyməsini basmaq seçilmiş açar sözü, cədvəli və ya sütunu təsdiqləyir və boşluğu saxlayır. Enter və Tab əvvəlki kimi işləyir.",
|
||||
functionCompletionIncludeParams: "Funksiya tamamlamasında parametr nümunələrini daxil et",
|
||||
functionCompletionIncludeParamsDescription: "Funksiyaları tamamlayarkən mötərizə içində yer tutucu parametr nümunələrini əlavə edin. Deaktiv edildikdə yalnız mötərizələr əlavə edilir və kursor içəridə yerləşdirilir.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Açar axtarışı şablonları",
|
||||
redisKeyTemplatesPlaceholder: "Nümunə:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -8603,6 +8603,8 @@ export default {
|
||||
autoAliasTablesDescription: "When selecting a table completion in FROM or JOIN, insert a generated alias such as order_items AS oi.",
|
||||
sqlServerSpaceConfirmsCompletion: "Space confirms completion (SQL Server style)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "While the completion list is open, pressing Space accepts the selected keyword, table, or column and keeps the trailing space. Enter and Tab behave as before.",
|
||||
functionCompletionIncludeParams: "Include parameter examples in function completion",
|
||||
functionCompletionIncludeParamsDescription: "Include placeholder parameter examples inside parentheses when completing functions. When disabled, only the parentheses are inserted with the cursor placed inside.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Key search templates",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -7904,6 +7904,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "Al seleccionar una tabla en FROM o JOIN, inserta un alias generado como order_items AS oi.",
|
||||
sqlServerSpaceConfirmsCompletion: "Confirmar la sugerencia con espacio (estilo SQL Server)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "Con la lista de sugerencias abierta, pulsar espacio acepta la palabra clave, tabla o columna seleccionada y conserva el espacio. Intro y Tabulador no cambian.",
|
||||
functionCompletionIncludeParams: "Incluir ejemplos de parámetros en autocompletado de funciones",
|
||||
functionCompletionIncludeParamsDescription: "Incluir marcadores de posición de parámetros dentro de los paréntesis al autocompletar funciones. Si se desactiva, solo se insertan los paréntesis con el cursor dentro.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Plantillas de búsqueda de claves",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -8387,6 +8387,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "Saat memilih pelengkapan tabel di FROM atau JOIN, sisipkan alias yang dihasilkan seperti order_items AS oi.",
|
||||
sqlServerSpaceConfirmsCompletion: "Spasi mengonfirmasi pelengkapan (gaya SQL Server)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "Saat daftar pelengkapan terbuka, menekan Spasi akan menerima kata kunci, tabel, atau kolom yang dipilih serta mempertahankan spasi di akhir. Enter dan Tab tetap berperilaku seperti sebelumnya.",
|
||||
functionCompletionIncludeParams: "Sertakan contoh parameter dalam pelengkapan fungsi",
|
||||
functionCompletionIncludeParamsDescription: "Sertakan contoh placeholder parameter di dalam tanda kurung saat melengkapi fungsi. Jika dinonaktifkan, hanya tanda kurung yang disisipkan dengan kursor di dalamnya.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Template pencarian key",
|
||||
redisKeyTemplatesPlaceholder: "Contoh:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -7666,6 +7666,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "Quando scegli una tabella in FROM o JOIN, inserisce un alias generato come order_items AS oi.",
|
||||
sqlServerSpaceConfirmsCompletion: "Conferma il completamento con lo spazio (stile SQL Server)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "Con l'elenco dei suggerimenti aperto, premendo spazio si accetta la parola chiave, la tabella o la colonna selezionata mantenendo lo spazio. Invio e Tab restano invariati.",
|
||||
functionCompletionIncludeParams: "Includi esempi di parametri nel completamento funzioni",
|
||||
functionCompletionIncludeParamsDescription: "Include segnaposto per i parametri tra parentesi durante il completamento delle funzioni. Quando disattivato, inserisce solo le parentesi con il cursore posizionato all'interno.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Modelli di ricerca chiavi",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -7669,6 +7669,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "FROM または JOIN でテーブル補完を選択すると、order_items AS oi のような生成済み別名を挿入します。",
|
||||
sqlServerSpaceConfirmsCompletion: "スペースで補完を確定(SQL Server 方式)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "補完リストの表示中にスペースを押すと、選択中のキーワード・テーブル・列を確定し、空白を保持します。Enter と Tab は従来どおり動作します。",
|
||||
functionCompletionIncludeParams: "関数補全に引数プレースホルダーを含める",
|
||||
functionCompletionIncludeParamsDescription: "関数補全の確定時に括弧内に引数のプレースホルダーを含めます。無効にすると括弧のみが補全され、カーソルが括弧内に配置されます。",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "キー検索テンプレート",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -7476,6 +7476,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "FROM이나 JOIN에서 테이블 완성을 선택할 때 order_items AS oi 같은 생성된 별칭을 삽입합니다.",
|
||||
sqlServerSpaceConfirmsCompletion: "공백으로 완성 확정(SQL Server 방식)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "완성 목록이 열려 있을 때 공백을 누르면 선택한 키워드, 테이블 또는 컬럼을 확정하고 공백을 유지합니다. Enter와 Tab은 기존과 동일하게 동작합니다.",
|
||||
functionCompletionIncludeParams: "함수 완성 시 매개변수 예시 포함",
|
||||
functionCompletionIncludeParamsDescription: "함수 완성 시 괄호 안에 매개변수 플레이스홀더 예시를 포함합니다. 비활성화하면 괄호만 완성되고 커서가 괄호 안에 위치합니다.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "키 검색 템플릿",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -7667,6 +7667,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "Ao escolher uma tabela em FROM ou JOIN, insere um alias gerado como order_items AS oi.",
|
||||
sqlServerSpaceConfirmsCompletion: "Confirmar a conclusão com espaço (estilo SQL Server)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "Com a lista de sugestões aberta, pressionar espaço aceita a palavra-chave, tabela ou coluna selecionada e mantém o espaço. Enter e Tab continuam iguais.",
|
||||
functionCompletionIncludeParams: "Incluir exemplos de parâmetros no preenchimento de funções",
|
||||
functionCompletionIncludeParamsDescription: "Incluir marcadores de posição de parâmetros dentro dos parênteses ao autocompletar funções. Quando desativado, apenas os parênteses são inseridos com o cursor posicionado dentro.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Modelos de busca de chave",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -8907,6 +8907,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "При выборе автодополнения таблицы в FROM или JOIN вставлять сгенерированный псевдоним, например order_items AS oi.",
|
||||
sqlServerSpaceConfirmsCompletion: "Пробел подтверждает автодополнение (стиль SQL Server)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "Пока список автодополнения открыт, нажатие пробела принимает выбранное ключевое слово, таблицу или столбец и сохраняет пробел. Enter и Tab работают как раньше.",
|
||||
functionCompletionIncludeParams: "Примеры параметров при автодополнении функций",
|
||||
functionCompletionIncludeParamsDescription: "Включать примеры параметров внутри скобок при автодополнении функций. Если выключено, вставляются только скобки с курсором внутри.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Шаблоны поиска ключей",
|
||||
redisKeyTemplatesPlaceholder: "Пример:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -7564,6 +7564,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "FROM veya JOIN içinde bir tablo tamamlaması seçildiğinde order_items AS oi gibi üretilmiş bir takma ad ekle.",
|
||||
sqlServerSpaceConfirmsCompletion: "Boşlukla tamamlamayı onayla (SQL Server tarzı)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "Tamamlama listesi açıkken boşluk tuşuna basmak seçili anahtar sözcüğü, tabloyu veya sütunu onaylar ve boşluğu korur. Enter ve Tab aynı kalır.",
|
||||
functionCompletionIncludeParams: "Fonksiyon tamamlamada parametre örneklerini ekle",
|
||||
functionCompletionIncludeParamsDescription: "Fonksiyonlar tamamlanırken parantez içine yer tutucu parametre örnekleri ekleyin. Devre dışı bırakıldığında yalnızca parantezler eklenir ve imleç içine yerleştirilir.",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Anahtar arama şablonları",
|
||||
redisKeyTemplatesPlaceholder: "Örnek:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -8586,6 +8586,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "补全 FROM 或 JOIN 表名时自动添加别名。",
|
||||
sqlServerSpaceConfirmsCompletion: "空格确认补全(SQL Server 习惯)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "补全列表打开时,按空格直接采用选中的关键字、表名或列名,并保留空格。Enter 和 Tab 保持原有行为。",
|
||||
functionCompletionIncludeParams: "函数补全带参数示例",
|
||||
functionCompletionIncludeParamsDescription: "使用函数补全时,是否在括号内附带参数占位示例;关闭后仅补全括号并将光标置于括号内。",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Key 搜索模板",
|
||||
redisKeyTemplatesPlaceholder: "例如:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -7012,6 +7012,8 @@ export default withEnglishFallback({
|
||||
autoAliasTablesDescription: "在 FROM 或 JOIN 中選擇資料表補全時,自動插入類似 order_items AS oi 的資料表別名。",
|
||||
sqlServerSpaceConfirmsCompletion: "空格確認補全(SQL Server 習慣)",
|
||||
sqlServerSpaceConfirmsCompletionDescription: "補全清單開啟時,按空格直接採用選取的關鍵字、資料表或欄名,並保留空格。Enter 與 Tab 維持原本行為。",
|
||||
functionCompletionIncludeParams: "函數補全帶參數範例",
|
||||
functionCompletionIncludeParamsDescription: "使用函數補全時,是否在括號內附帶參數佔位範例;關閉後僅補全括號並將游標置於括號內。",
|
||||
redisKeyTemplatesSection: "Redis",
|
||||
redisKeyTemplates: "Key 搜尋模板",
|
||||
redisKeyTemplatesPlaceholder: "例如:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
|
||||
@@ -106,3 +106,62 @@ describe("SQL function completion across dialects", () => {
|
||||
expect(trinoFunctions).not.toContain("GET_JSON_OBJECT");
|
||||
});
|
||||
});
|
||||
|
||||
describe("functionCompletionIncludeParams setting", () => {
|
||||
it("includes parameter placeholders by default and when explicitly true", () => {
|
||||
const itemsDefault = buildSqlCompletionItems("SELECT COUN", 11, { databaseType: "postgres", tables: [], columnsByTable: new Map() });
|
||||
const countDefault = itemsDefault.find((item) => item.label === "COUNT");
|
||||
expect(countDefault?.apply).toBe("COUNT(${expression})");
|
||||
|
||||
const itemsTrue = buildSqlCompletionItems("SELECT COUN", 11, { databaseType: "postgres", tables: [], columnsByTable: new Map(), functionCompletionIncludeParams: true });
|
||||
const countTrue = itemsTrue.find((item) => item.label === "COUNT");
|
||||
expect(countTrue?.apply).toBe("COUNT(${expression})");
|
||||
});
|
||||
|
||||
it("omits parameter placeholders and places cursor inside parentheses when false", () => {
|
||||
const items = buildSqlCompletionItems("SELECT COUN", 11, { databaseType: "postgres", tables: [], columnsByTable: new Map(), functionCompletionIncludeParams: false });
|
||||
const count = items.find((item) => item.label === "COUNT");
|
||||
expect(count?.apply).toBe("COUNT(${})");
|
||||
});
|
||||
|
||||
it("omits parameter placeholders for templated functions when false", () => {
|
||||
const itemsWith = buildSqlCompletionItems("SELECT POSI", 11, { databaseType: "postgres", tables: [], columnsByTable: new Map(), functionCompletionIncludeParams: true });
|
||||
expect(itemsWith.find((item) => item.label === "POSITION")?.apply).toBe("POSITION(${substring} IN ${string})");
|
||||
|
||||
const itemsWithout = buildSqlCompletionItems("SELECT POSI", 11, { databaseType: "postgres", tables: [], columnsByTable: new Map(), functionCompletionIncludeParams: false });
|
||||
expect(itemsWithout.find((item) => item.label === "POSITION")?.apply).toBe("POSITION(${})");
|
||||
});
|
||||
|
||||
it("omits partition/order by parameter examples for window functions when false", () => {
|
||||
const itemsWith = buildSqlCompletionItems("SELECT ROW_", 11, { databaseType: "postgres", tables: [], columnsByTable: new Map(), functionCompletionIncludeParams: true });
|
||||
expect(itemsWith.find((item) => item.label === "ROW_NUMBER")?.apply).toBe("ROW_NUMBER() OVER (PARTITION BY ${col} ORDER BY ${col})");
|
||||
|
||||
const itemsWithout = buildSqlCompletionItems("SELECT ROW_", 11, { databaseType: "postgres", tables: [], columnsByTable: new Map(), functionCompletionIncludeParams: false });
|
||||
expect(itemsWithout.find((item) => item.label === "ROW_NUMBER")?.apply).toBe("ROW_NUMBER() OVER (${})");
|
||||
});
|
||||
|
||||
it("supports user routine completion without parameter placeholders", () => {
|
||||
const routineObject = {
|
||||
name: "calculate_total",
|
||||
type: "function" as const,
|
||||
signature: "p_price numeric, p_qty int",
|
||||
};
|
||||
const itemsWith = buildSqlCompletionItems("SELECT calc", 11, {
|
||||
databaseType: "postgres",
|
||||
tables: [],
|
||||
columnsByTable: new Map(),
|
||||
objects: [routineObject],
|
||||
functionCompletionIncludeParams: true,
|
||||
});
|
||||
expect(itemsWith.find((item) => item.label === "calculate_total")?.apply).toBe("calculate_total(${1:p_price numeric}, ${2:p_qty int})");
|
||||
|
||||
const itemsWithout = buildSqlCompletionItems("SELECT calc", 11, {
|
||||
databaseType: "postgres",
|
||||
tables: [],
|
||||
columnsByTable: new Map(),
|
||||
objects: [routineObject],
|
||||
functionCompletionIncludeParams: false,
|
||||
});
|
||||
expect(itemsWithout.find((item) => item.label === "calculate_total")?.apply).toBe("calculate_total(${})");
|
||||
});
|
||||
});
|
||||
@@ -167,6 +167,15 @@ describe("EDITOR_SETTINGS_DRAFT_KEYS", () => {
|
||||
it("includes the SQL variable substitution master switch", () => {
|
||||
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("sqlVariableSubstitutionEnabled");
|
||||
});
|
||||
|
||||
it("includes functionCompletionIncludeParams in draft keys, draft conversion, and patch", () => {
|
||||
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("functionCompletionIncludeParams");
|
||||
const draft = editorSettingsDraftFromSettings(makeSettings({ functionCompletionIncludeParams: false }));
|
||||
const base = editorSettingsDraftFromSettings(makeSettings({ functionCompletionIncludeParams: true }));
|
||||
expect(draft.functionCompletionIncludeParams).toBe(false);
|
||||
expect(editorSettingsDraftChanged(draft, base)).toBe(true);
|
||||
expect(editorSettingsPatchFromDraft(draft, base)).toEqual({ functionCompletionIncludeParams: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe("editorSettingsDraftFromSettings", () => {
|
||||
|
||||
@@ -299,6 +299,7 @@ describe("settings search", () => {
|
||||
{ titleKey: "toolbar.theme", category: "appearance", targetId: "appearance" },
|
||||
{ titleKey: "settings.sidebarObjectInfoMode", category: "navigation", targetId: "navigation" },
|
||||
{ titleKey: "settings.insertSpaceAfterCompletion", category: "editor", targetId: "editor" },
|
||||
{ titleKey: "settings.functionCompletionIncludeParams", category: "editor", targetId: "editor" },
|
||||
{ titleKey: "settings.completionTriggerMode", category: "editor", targetId: "editor" },
|
||||
{ titleKey: "settings.tableCompletionSchemaQualification", category: "editor", targetId: "editor" },
|
||||
{ titleKey: "settings.autoAliasTables", category: "editor", targetId: "editor" },
|
||||
|
||||
@@ -23,6 +23,15 @@ describe("settingsTransfer", () => {
|
||||
expect(parseSettingsTransferFile(fileWith({ resultTabPreferComments: "false" })).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("round-trips functionCompletionIncludeParams as an editor setting and rejects non-booleans", () => {
|
||||
const text = serializeSettingsTransfer({ ...DEFAULT_EDITOR_SETTINGS, functionCompletionIncludeParams: false });
|
||||
const result = parseSettingsTransferFile(text);
|
||||
expect(result.ok).toBe(true);
|
||||
if (result.ok) expect(result.value.editorSettings.functionCompletionIncludeParams).toBe(false);
|
||||
expect(transferCategoryForKey("functionCompletionIncludeParams")).toBe("editor");
|
||||
expect(parseSettingsTransferFile(fileWith({ functionCompletionIncludeParams: "false" })).ok).toBe(false);
|
||||
});
|
||||
|
||||
it("round-trips the welcome page mode and rejects invalid values", () => {
|
||||
const result = parseSettingsTransferFile(fileWith({ welcomePageMode: "workspace" }));
|
||||
expect(result.ok).toBe(true);
|
||||
|
||||
@@ -30,6 +30,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
|
||||
"tableCompletionSchemaQualification",
|
||||
"insertSpaceAfterCompletion",
|
||||
"sqlServerSpaceConfirmsCompletion",
|
||||
"functionCompletionIncludeParams",
|
||||
"snippetTriggerKey",
|
||||
"sortCompletionColumnsAlphabetically",
|
||||
"selectFirstCompletionOnOpen",
|
||||
|
||||
@@ -147,6 +147,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
|
||||
{ id: "editor-double-click-string", category: "editor", titleKey: "settings.doubleClickStringSelectionMode", descriptionKey: "settings.doubleClickStringSelectionModeDescription", targetId: "editor" },
|
||||
{ id: "editor-completion-spacing", category: "editor", titleKey: "settings.insertSpaceAfterCompletion", descriptionKey: "settings.insertSpaceAfterCompletionDescription", targetId: "editor" },
|
||||
{ id: "editor-sqlserver-space-completion", category: "editor", titleKey: "settings.sqlServerSpaceConfirmsCompletion", descriptionKey: "settings.sqlServerSpaceConfirmsCompletionDescription", targetId: "editor", visible: sqlServerSpaceCompletionVisible },
|
||||
{ id: "editor-function-completion-include-params", category: "editor", titleKey: "settings.functionCompletionIncludeParams", descriptionKey: "settings.functionCompletionIncludeParamsDescription", targetId: "editor" },
|
||||
{ id: "editor-completion-trigger-mode", category: "editor", titleKey: "settings.completionTriggerMode", descriptionKey: "settings.completionTriggerModeDescription", targetId: "editor" },
|
||||
{ id: "editor-table-completion-schema-qualification", category: "editor", titleKey: "settings.tableCompletionSchemaQualification", descriptionKey: "settings.tableCompletionSchemaQualificationDescription", targetId: "editor" },
|
||||
{ id: "editor-auto-alias", category: "editor", titleKey: "settings.autoAliasTables", descriptionKey: "settings.autoAliasTablesDescription", targetId: "editor" },
|
||||
|
||||
@@ -86,6 +86,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readon
|
||||
"tableCompletionSchemaQualification",
|
||||
"insertSpaceAfterCompletion",
|
||||
"sqlServerSpaceConfirmsCompletion",
|
||||
"functionCompletionIncludeParams",
|
||||
"sortCompletionColumnsAlphabetically",
|
||||
"selectFirstCompletionOnOpen",
|
||||
"completionTriggerMode",
|
||||
@@ -282,6 +283,7 @@ const PASS_THROUGH_BOOLEAN_KEYS = [
|
||||
"showWhitespace",
|
||||
"showExecutionTargetPicker",
|
||||
"autoAliasTables",
|
||||
"functionCompletionIncludeParams",
|
||||
"confirmDangerousSqlExecution",
|
||||
"confirmUnsavedSqlClose",
|
||||
"showColumnCommentsInHeader",
|
||||
|
||||
@@ -1649,6 +1649,7 @@ export interface SqlCompletionProviderInput {
|
||||
autoAliasTables?: boolean;
|
||||
tableCompletionSchemaQualification?: SqlTableCompletionSchemaQualification;
|
||||
quoteIdentifiers?: boolean;
|
||||
functionCompletionIncludeParams?: boolean;
|
||||
}
|
||||
|
||||
export function buildSqlCompletionItems(
|
||||
@@ -1670,6 +1671,7 @@ export function buildSqlCompletionItems(
|
||||
autoAliasTables?: boolean;
|
||||
tableCompletionSchemaQualification?: SqlTableCompletionSchemaQualification;
|
||||
quoteIdentifiers?: boolean;
|
||||
functionCompletionIncludeParams?: boolean;
|
||||
},
|
||||
): SqlCompletionItem[] {
|
||||
if (isSqlCompletionSuppressedContext(sql, cursor, input)) return [];
|
||||
@@ -1738,7 +1740,7 @@ class SqlCompletionProvider {
|
||||
this.items.push(...buildSnippetItems(context.prefix, snippets.filter(shouldFormatBuiltinSnippet), this.input.keywordCase, this.databaseType));
|
||||
}
|
||||
if (!preferReferencedColumns || context.suggestRoutines) {
|
||||
const functionItems = context.dataTypeContext ? [] : buildFunctionSnippetItems(context.prefix, getFunctionDescriptions(this.t), this.databaseType, context.openingParenAfterCursor, this.input.keywordCase, this.input.functionCase);
|
||||
const functionItems = context.dataTypeContext ? [] : buildFunctionSnippetItems(context.prefix, getFunctionDescriptions(this.t), this.databaseType, context.openingParenAfterCursor, this.input.keywordCase, this.input.functionCase, this.input.functionCompletionIncludeParams);
|
||||
this.items.push(...(preferReferencedColumns ? functionItems.filter((item) => item.label.toLowerCase().startsWith(context.prefix.toLowerCase())) : functionItems));
|
||||
if (isOracleLikeDatabase(this.databaseType)) {
|
||||
this.items.push(...buildOracleSystemValueItems(context.prefix, this.input.keywordCase));
|
||||
@@ -1806,10 +1808,10 @@ class SqlCompletionProvider {
|
||||
this.items.push(...buildForeignKeyRelatedTableItems(context, completionTables, this.input.foreignKeysByTable, this.dialect, autoAliasTables, this.databaseType, this.input.currentSchema, schemaQualification));
|
||||
this.items.push(...buildTableItems(context, completionTables, this.dialect, autoAliasTables, context.referencedTables, this.databaseType, this.input.currentSchema, schemaQualification));
|
||||
if (this.databaseType === "clickhouse") {
|
||||
this.items.push(...buildClickHouseFunctionItems(context.prefix, context.openingParenAfterCursor, "table"));
|
||||
this.items.push(...buildClickHouseFunctionItems(context.prefix, context.openingParenAfterCursor, "table", this.input.functionCompletionIncludeParams));
|
||||
}
|
||||
if (isOracleLikeDatabase(this.databaseType)) {
|
||||
this.items.push(...buildOracleTableFunctionItems(context.prefix, this.input.keywordCase, this.input.functionCase));
|
||||
this.items.push(...buildOracleTableFunctionItems(context.prefix, this.input.keywordCase, this.input.functionCase, this.input.functionCompletionIncludeParams));
|
||||
}
|
||||
if (this.input.schemas && this.input.schemas.length > 0) {
|
||||
this.items.push(...buildSchemaItems(context.prefix, this.input.schemas, this.dialect));
|
||||
@@ -1818,7 +1820,7 @@ class SqlCompletionProvider {
|
||||
|
||||
if (context.suggestRoutines || context.exclusiveRoutineSuggestions || context.oracleTableFunctionContext) {
|
||||
const profileObjects = driverProfileCompletionObjects(this.input.driverProfile, context);
|
||||
this.items.push(...buildObjectItems(context, [...(this.input.objects ?? []), ...profileObjects], this.dialect, this.databaseType, this.input.currentSchema));
|
||||
this.items.push(...buildObjectItems(context, [...(this.input.objects ?? []), ...profileObjects], this.dialect, this.databaseType, this.input.currentSchema, this.input.functionCompletionIncludeParams));
|
||||
}
|
||||
|
||||
if (context.comparisonLeftColumn && context.suggestKeywords) {
|
||||
@@ -4246,7 +4248,7 @@ function buildSchemaItems(prefix: string, schemas: string[], dialect?: SqlComple
|
||||
}));
|
||||
}
|
||||
|
||||
function buildObjectItems(context: SqlCompletionContext, objects: SqlCompletionObject[], dialect?: SqlCompletionApplyDialect, databaseType?: DatabaseType, currentSchema?: string): SqlCompletionItem[] {
|
||||
function buildObjectItems(context: SqlCompletionContext, objects: SqlCompletionObject[], dialect?: SqlCompletionApplyDialect, databaseType?: DatabaseType, currentSchema?: string, includeParams = true): SqlCompletionItem[] {
|
||||
if (completionQualifierIsReferencedTable(context)) return [];
|
||||
const onlyProcedures = context.contextKind === "exec";
|
||||
const onlyFunctions = context.suggestColumns && context.referencedTables.length > 0 && !context.qualifier;
|
||||
@@ -4272,7 +4274,7 @@ function buildObjectItems(context: SqlCompletionContext, objects: SqlCompletionO
|
||||
type: "function" as const,
|
||||
detail,
|
||||
info: buildRoutineInfo(object),
|
||||
apply: object.type === "trigger" || object.type === "package" ? applyName : buildRoutineApply(applyName, object.signature),
|
||||
apply: object.type === "trigger" || object.type === "package" ? applyName : buildRoutineApply(applyName, object.signature, includeParams),
|
||||
boost: computeBoost(object.name, context.prefix) + typeBoost + schemaBoost,
|
||||
dedupeKey: signature ? `${baseDedupeKey ?? object.name}(${signature})` : baseDedupeKey,
|
||||
// Preserve exact routine matches before the capped candidate list is truncated.
|
||||
@@ -4283,9 +4285,10 @@ function buildObjectItems(context: SqlCompletionContext, objects: SqlCompletionO
|
||||
.slice(0, MAX_TABLE_COMPLETION_ITEMS);
|
||||
}
|
||||
|
||||
function buildRoutineApply(applyName: string, signature?: string): string {
|
||||
function buildRoutineApply(applyName: string, signature?: string, includeParams = true): string {
|
||||
const parameters = splitRoutineSignatureParameters(signature?.trim() ?? "");
|
||||
if (parameters.length === 0) return `${applyName}()`;
|
||||
if (!includeParams) return `${applyName}(\${})`;
|
||||
return `${applyName}(${parameters.map((parameter, index) => `\${${index + 1}:${escapeSnippetFieldName(parameter)}}`).join(", ")})`;
|
||||
}
|
||||
|
||||
@@ -4372,12 +4375,12 @@ function objectMatchesCompletionContext(object: SqlCompletionObject, context: Sq
|
||||
return matchesPrefix(object.name, context.prefix);
|
||||
}
|
||||
|
||||
function buildOracleTableFunctionItems(prefix: string, keywordCase?: SqlKeywordCase, functionCase?: SqlKeywordCase): SqlCompletionItem[] {
|
||||
function buildOracleTableFunctionItems(prefix: string, keywordCase?: SqlKeywordCase, functionCase?: SqlKeywordCase, includeParams = true): SqlCompletionItem[] {
|
||||
const items = [
|
||||
{ label: applySqlKeywordCase("TABLE", keywordCase), detail: "Oracle table function", apply: `${applySqlKeywordCase("TABLE", keywordCase)}(\${function_call})` },
|
||||
{ label: applySqlKeywordCase("THE", keywordCase), detail: "Oracle nested-table expression", apply: `${applySqlKeywordCase("THE", keywordCase)}(\${subquery})` },
|
||||
{ label: applySqlFunctionCase("XMLTABLE", functionCase), detail: "XML to relational rows", apply: `${applySqlFunctionCase("XMLTABLE", functionCase)}(\${xpath})` },
|
||||
{ label: applySqlFunctionCase("JSON_TABLE", functionCase), detail: "JSON to relational rows", apply: `${applySqlFunctionCase("JSON_TABLE", functionCase)}(\${expr}, \${path})` },
|
||||
{ label: applySqlKeywordCase("TABLE", keywordCase), detail: "Oracle table function", apply: includeParams ? `${applySqlKeywordCase("TABLE", keywordCase)}(\${function_call})` : `${applySqlKeywordCase("TABLE", keywordCase)}(\${})` },
|
||||
{ label: applySqlKeywordCase("THE", keywordCase), detail: "Oracle nested-table expression", apply: includeParams ? `${applySqlKeywordCase("THE", keywordCase)}(\${subquery})` : `${applySqlKeywordCase("THE", keywordCase)}(\${})` },
|
||||
{ label: applySqlFunctionCase("XMLTABLE", functionCase), detail: "XML to relational rows", apply: includeParams ? `${applySqlFunctionCase("XMLTABLE", functionCase)}(\${xpath})` : `${applySqlFunctionCase("XMLTABLE", functionCase)}(\${})` },
|
||||
{ label: applySqlFunctionCase("JSON_TABLE", functionCase), detail: "JSON to relational rows", apply: includeParams ? `${applySqlFunctionCase("JSON_TABLE", functionCase)}(\${expr}, \${path})` : `${applySqlFunctionCase("JSON_TABLE", functionCase)}(\${})` },
|
||||
];
|
||||
return items
|
||||
.filter((item) => matchesPrefix(item.label, prefix))
|
||||
@@ -5526,9 +5529,13 @@ function activeFunctionDescriptions(databaseType?: DatabaseType): Map<string, st
|
||||
return databaseType === "doris" || databaseType === "starrocks" ? DORIS_FUNCTION_DESCRIPTIONS : EMPTY_FUNCTION_DESCRIPTIONS;
|
||||
}
|
||||
|
||||
function formatFunctionSignatureApply(definition: ClickHouseFunctionDefinition, omitOpeningParen: boolean): string {
|
||||
function formatFunctionSignatureApply(definition: ClickHouseFunctionDefinition, omitOpeningParen: boolean, includeParams = true): string {
|
||||
if (omitOpeningParen) return definition.name;
|
||||
const signature = definition.signatures[definition.preferredSignature ?? 0];
|
||||
if (!includeParams) {
|
||||
const hasParams = signature.parameterGroups.some((group) => group.filter((parameter) => !parameter.endsWith("?")).length > 0);
|
||||
return hasParams ? `${definition.name}(\${})` : `${definition.name}()`;
|
||||
}
|
||||
return (
|
||||
definition.name +
|
||||
signature.parameterGroups
|
||||
@@ -5549,7 +5556,7 @@ function clickHouseFunctionDetail(definition: ClickHouseFunctionDefinition): str
|
||||
return `ClickHouse · ${definition.category}${overloads}${status}`;
|
||||
}
|
||||
|
||||
function buildClickHouseFunctionItems(prefix: string, omitOpeningParen: boolean, kind?: ClickHouseFunctionKind): SqlCompletionItem[] {
|
||||
function buildClickHouseFunctionItems(prefix: string, omitOpeningParen: boolean, kind?: ClickHouseFunctionKind, includeParams = true): SqlCompletionItem[] {
|
||||
return searchClickHouseFunctions(prefix, 200, kind).map((definition) => {
|
||||
const statusPenalty = definition.status === "deprecated" ? -600 : definition.status === "experimental" ? -300 : 0;
|
||||
const generatedPenalty = definition.generated ? -75 : 0;
|
||||
@@ -5558,14 +5565,14 @@ function buildClickHouseFunctionItems(prefix: string, omitOpeningParen: boolean,
|
||||
type: "function" as const,
|
||||
detail: clickHouseFunctionDetail(definition),
|
||||
info: definition.description,
|
||||
apply: formatFunctionSignatureApply(definition, omitOpeningParen),
|
||||
apply: formatFunctionSignatureApply(definition, omitOpeningParen, includeParams),
|
||||
boost: computeBoost(definition.name, prefix) + 300 + statusPenalty + generatedPenalty,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function buildFunctionSnippetItems(prefix: string, functionDescriptions: Map<string, string>, databaseType?: DatabaseType, omitOpeningParen = false, keywordCase?: SqlKeywordCase, functionCase?: SqlKeywordCase): SqlCompletionItem[] {
|
||||
if (databaseType === "clickhouse") return buildClickHouseFunctionItems(prefix, omitOpeningParen);
|
||||
function buildFunctionSnippetItems(prefix: string, functionDescriptions: Map<string, string>, databaseType?: DatabaseType, omitOpeningParen = false, keywordCase?: SqlKeywordCase, functionCase?: SqlKeywordCase, includeParams = true): SqlCompletionItem[] {
|
||||
if (databaseType === "clickhouse") return buildClickHouseFunctionItems(prefix, omitOpeningParen, undefined, includeParams);
|
||||
const items: SqlCompletionItem[] = [];
|
||||
|
||||
for (const [name, parameters] of activeFunctionSignatures(databaseType).entries()) {
|
||||
@@ -5573,11 +5580,21 @@ function buildFunctionSnippetItems(prefix: string, functionDescriptions: Map<str
|
||||
const functionName = applySqlFunctionCase(name, functionCase);
|
||||
const paramStr = parameters.length > 0 ? parameters.map((p) => `\${${applyGeneratedSqlTemplateKeywordCase(p, keywordCase)}}`).join(", ") : "";
|
||||
const applyTemplate = functionApplyTemplate(databaseType, name);
|
||||
let apply: string;
|
||||
if (omitOpeningParen) {
|
||||
apply = functionName;
|
||||
} else if (!includeParams) {
|
||||
apply = parameters.length > 0 ? `${functionName}(\${})` : `${functionName}()`;
|
||||
} else if (applyTemplate) {
|
||||
apply = `${functionName}${applyGeneratedSqlTemplateKeywordCase(applyTemplate.slice(name.length), keywordCase)}`;
|
||||
} else {
|
||||
apply = `${functionName}(${paramStr})`;
|
||||
}
|
||||
items.push({
|
||||
label: functionName,
|
||||
type: "function" as const,
|
||||
detail: activeFunctionDescriptions(databaseType).get(name) ?? functionDescriptions.get(name) ?? "function",
|
||||
apply: applyTemplate ? `${functionName}${applyGeneratedSqlTemplateKeywordCase(applyTemplate.slice(name.length), keywordCase)}` : `${functionName}(${paramStr})`,
|
||||
apply,
|
||||
boost: computeBoost(name, prefix) + 300,
|
||||
});
|
||||
}
|
||||
@@ -5586,11 +5603,12 @@ function buildFunctionSnippetItems(prefix: string, functionDescriptions: Map<str
|
||||
for (const name of WINDOW_FUNCTIONS) {
|
||||
if (!matchesPrefix(name, prefix)) continue;
|
||||
const functionName = applySqlFunctionCase(name, functionCase);
|
||||
const apply = omitOpeningParen ? functionName : includeParams ? applyGeneratedSqlTemplateKeywordCase(`${functionName}() OVER (PARTITION BY \${col} ORDER BY \${col})`, keywordCase) : applyGeneratedSqlTemplateKeywordCase(`${functionName}() OVER (\${})`, keywordCase);
|
||||
items.push({
|
||||
label: functionName,
|
||||
type: "function" as const,
|
||||
detail: "window function",
|
||||
apply: applyGeneratedSqlTemplateKeywordCase(`${functionName}() OVER (PARTITION BY \${col} ORDER BY \${col})`, keywordCase),
|
||||
apply,
|
||||
boost: computeBoost(name, prefix) + 250,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -364,6 +364,13 @@ describe("normalizeEditorSettings", () => {
|
||||
expect(normalizeEditorSettings({ sqlServerSpaceConfirmsCompletion: "yes" as unknown as boolean }).sqlServerSpaceConfirmsCompletion).toBe(false);
|
||||
});
|
||||
|
||||
it("enables function completion parameter examples by default and preserves an explicit opt-out", () => {
|
||||
expect(DEFAULT_EDITOR_SETTINGS.functionCompletionIncludeParams).toBe(true);
|
||||
expect(normalizeEditorSettings({}).functionCompletionIncludeParams).toBe(true);
|
||||
expect(normalizeEditorSettings({ functionCompletionIncludeParams: false }).functionCompletionIncludeParams).toBe(false);
|
||||
expect(normalizeEditorSettings({ functionCompletionIncludeParams: "yes" as unknown as boolean }).functionCompletionIncludeParams).toBe(true);
|
||||
});
|
||||
|
||||
it("defaults snippetTriggerKey to tab and preserves valid options while falling back on invalid values", () => {
|
||||
expect(normalizeEditorSettings({}).snippetTriggerKey).toBe("tab");
|
||||
expect(normalizeEditorSettings({ snippetTriggerKey: "tab" }).snippetTriggerKey).toBe("tab");
|
||||
|
||||
@@ -885,6 +885,7 @@ export interface EditorSettings {
|
||||
tableCompletionSchemaQualification: SqlTableCompletionSchemaQualification;
|
||||
insertSpaceAfterCompletion: boolean;
|
||||
sqlServerSpaceConfirmsCompletion: boolean;
|
||||
functionCompletionIncludeParams: boolean;
|
||||
sortCompletionColumnsAlphabetically: boolean;
|
||||
selectFirstCompletionOnOpen: boolean;
|
||||
wordWrap: boolean;
|
||||
@@ -1220,6 +1221,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
||||
tableCompletionSchemaQualification: DEFAULT_SQL_TABLE_COMPLETION_SCHEMA_QUALIFICATION,
|
||||
insertSpaceAfterCompletion: true,
|
||||
sqlServerSpaceConfirmsCompletion: false,
|
||||
functionCompletionIncludeParams: true,
|
||||
snippetTriggerKey: "tab",
|
||||
sortCompletionColumnsAlphabetically: true,
|
||||
selectFirstCompletionOnOpen: true,
|
||||
@@ -1831,6 +1833,7 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
|
||||
tableCompletionSchemaQualification: normalizeSqlTableCompletionSchemaQualification(settings.tableCompletionSchemaQualification),
|
||||
insertSpaceAfterCompletion: typeof settings.insertSpaceAfterCompletion === "boolean" ? settings.insertSpaceAfterCompletion : DEFAULT_EDITOR_SETTINGS.insertSpaceAfterCompletion,
|
||||
sqlServerSpaceConfirmsCompletion: typeof settings.sqlServerSpaceConfirmsCompletion === "boolean" ? settings.sqlServerSpaceConfirmsCompletion : DEFAULT_EDITOR_SETTINGS.sqlServerSpaceConfirmsCompletion,
|
||||
functionCompletionIncludeParams: typeof settings.functionCompletionIncludeParams === "boolean" ? settings.functionCompletionIncludeParams : DEFAULT_EDITOR_SETTINGS.functionCompletionIncludeParams,
|
||||
snippetTriggerKey: settings.snippetTriggerKey === "space" || settings.snippetTriggerKey === "both" ? settings.snippetTriggerKey : DEFAULT_EDITOR_SETTINGS.snippetTriggerKey,
|
||||
sortCompletionColumnsAlphabetically: typeof settings.sortCompletionColumnsAlphabetically === "boolean" ? settings.sortCompletionColumnsAlphabetically : DEFAULT_EDITOR_SETTINGS.sortCompletionColumnsAlphabetically,
|
||||
selectFirstCompletionOnOpen: typeof settings.selectFirstCompletionOnOpen === "boolean" ? settings.selectFirstCompletionOnOpen : DEFAULT_EDITOR_SETTINGS.selectFirstCompletionOnOpen,
|
||||
@@ -2686,6 +2689,7 @@ export const useSettingsStore = defineStore("settings", () => {
|
||||
if (partial.tableCompletionSchemaQualification !== undefined) editorSettings.value.tableCompletionSchemaQualification = normalizeSqlTableCompletionSchemaQualification(partial.tableCompletionSchemaQualification);
|
||||
if (partial.insertSpaceAfterCompletion !== undefined) editorSettings.value.insertSpaceAfterCompletion = partial.insertSpaceAfterCompletion === true;
|
||||
if (partial.sqlServerSpaceConfirmsCompletion !== undefined) editorSettings.value.sqlServerSpaceConfirmsCompletion = partial.sqlServerSpaceConfirmsCompletion === true;
|
||||
if (partial.functionCompletionIncludeParams !== undefined) editorSettings.value.functionCompletionIncludeParams = partial.functionCompletionIncludeParams === true;
|
||||
if (partial.snippetTriggerKey !== undefined) editorSettings.value.snippetTriggerKey = partial.snippetTriggerKey === "space" || partial.snippetTriggerKey === "both" ? partial.snippetTriggerKey : "tab";
|
||||
if (partial.sortCompletionColumnsAlphabetically !== undefined) editorSettings.value.sortCompletionColumnsAlphabetically = partial.sortCompletionColumnsAlphabetically === true;
|
||||
if (partial.selectFirstCompletionOnOpen !== undefined) editorSettings.value.selectFirstCompletionOnOpen = partial.selectFirstCompletionOnOpen === true;
|
||||
|
||||
Reference in new issue
Block a user