File tree 2 files changed +15
-9
lines changed
packages/language-server/src
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,9 @@ describe('Completions', function () {
202
202
schema : /* Prisma */ `
203
203
generator client {
204
204
provider = "prisma-client-js"
205
- previewFeatures = ["views"]
205
+ // ! Assures we are reading the correct previewFeatures section.
206
+ // previewFeatures = []
207
+ previewFeatures = ["views"]
206
208
}
207
209
|
208
210
` ,
Original file line number Diff line number Diff line change @@ -32,15 +32,19 @@ export function getFirstDatasourceProvider(schema: PrismaSchema): string | undef
32
32
}
33
33
34
34
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 = / p r e v i e w F e a t u r e s \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/2
45
+ */
46
+ const previewFeaturesRegex = / ^ \s * (? ! \/ \/ \s ) p r e v i e w F e a t u r e s \s * = \s * ( \[ .* \] ) / m
38
47
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
- // }
44
48
const result = schema . findWithRegex ( previewFeaturesRegex )
45
49
46
50
if ( ! result || ! result . match [ 1 ] ) {
You can’t perform that action at this time.
0 commit comments