Skip to content

Commit

Permalink
fix(ls): remove completions for postgres type: (done from prisma-fmt)
Browse files Browse the repository at this point in the history
Closes #1139
  • Loading branch information
Jolg42 committed Jun 22, 2022
1 parent 9d77a15 commit 77c164b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 38 deletions.
6 changes: 5 additions & 1 deletion packages/language-server/src/__test__/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,12 @@ suite('Completions', function () {
expected: {
isIncomplete: false,
items: [
{ label: 'Hash', kind: CompletionItemKind.Enum },
{ label: 'BTree', kind: CompletionItemKind.Enum },
{ label: 'Hash', kind: CompletionItemKind.Enum },
{ label: 'Gist', kind: CompletionItemKind.Enum },
{ label: 'Gin', kind: CompletionItemKind.Enum },
{ label: 'SpGist', kind: CompletionItemKind.Enum },
{ label: 'Brin', kind: CompletionItemKind.Enum },
],
},
})
Expand Down
37 changes: 0 additions & 37 deletions packages/language-server/src/completion/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,43 +821,6 @@ function getSuggestionsForAttribute(
previewFeatures,
})
} else if (attribute === '@@index') {
// Auto completion for Hash and BTree for PostgreSQL
// includes because `@@index(type: |)` means wordBeforePosition = '@@index(type:'
// TODO figure out if we need to add cockroachdb provider here
if (
datasourceProvider &&
['postgresql', 'postgres'].includes(datasourceProvider) &&
wordBeforePosition.includes('type:')
) {
// TODO move away
const indexTypeCompletionItems: CompletionItem[] = [
{
label: 'Hash',
kind: CompletionItemKind.Enum,
insertTextFormat: InsertTextFormat.PlainText,
documentation: {
kind: 'markdown',
value:
'The Hash index can perform a faster lookup than a B-Tree index. However, the key downside of the Hash index is that its use is limited to equality operators that will perform matching operations.',
},
},
{
label: 'BTree',
kind: CompletionItemKind.Enum,
insertTextFormat: InsertTextFormat.PlainText,
documentation: {
kind: 'markdown',
value:
"The B-tree index is the default, it creates a self-balanced tree, in other words, it sorts itself. It will maintain its balance throughout operations such as insertions, deletions and searches. Using a B-tree index speeds up scan operations because it doesn't have to scan pages or records sequentially in a linear fashion.",
},
},
]
return {
items: indexTypeCompletionItems,
isIncomplete: false,
}
}

blockAtrributeArguments = givenBlockAttributeParams({
blockAttribute: '@@index',
wordBeforePosition,
Expand Down

0 comments on commit 77c164b

Please sign in to comment.