Skip to content

Commit 6f09510

Browse files
committed
fix #1741
1 parent bd82a1c commit 6f09510

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/language-server/src/lib/ast/configBlock.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ export function getFirstDatasourceProvider(schema: PrismaSchema): string | undef
3232
}
3333

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

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

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

0 commit comments

Comments
 (0)