Skip to content

Commit

Permalink
fix #1741
Browse files Browse the repository at this point in the history
  • Loading branch information
Druue committed May 27, 2024
1 parent bd82a1c commit 6f09510
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/language-server/src/lib/ast/configBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ export function getFirstDatasourceProvider(schema: PrismaSchema): string | undef
}

export function getAllPreviewFeaturesFromGenerators(schema: PrismaSchema): PreviewFeatures[] | undefined {
// matches any `previewFeatures = [x]` in any position
// thanks to https://regex101.com for the online scratchpad
const previewFeaturesRegex = /previewFeatures\s=\s(\[.*\])/g
/**
* ```prisma
* generator client {
* provider = "prisma-client-js"
* // previewFeatures = [] // This will be ignored
* previewFeatures = ["views"]
* }
* ```
*
* ? for more info: https://regex101.com/r/ezoTU2/1
*/
const previewFeaturesRegex = /^\s*(?!\/\/\s)previewFeatures\s=\s(\[.*\])/m

// we could match against all the `previewFeatures = [x]` (could be that there is more than one?)
// var matchAll = text.matchAll(regexp)
// for (const match of matchAll) {
// console.log(match);
// }
const result = schema.findWithRegex(previewFeaturesRegex)

if (!result || !result.match[1]) {
Expand Down

0 comments on commit 6f09510

Please sign in to comment.