diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..4a1f488 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18.17.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index c23f4f0..fd8221c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to the "vscode-glsllint" extension will be documented in thi Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. +## [1.8.1] + +### Fixed + +- Detection of shaders in string literals does not work with some strings [#68](https://github.com/hsimpson/vscode-glsllint/issues/68) + ## [1.8.x] ### Added diff --git a/package.json b/package.json index 7790794..f710ece 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vscode-glsllint", - "version": "1.8.0", + "version": "1.8.1", "publisher": "dtoplak", "repository": { "type": "git", diff --git a/src/features/glsllintProvider.ts b/src/features/glsllintProvider.ts index 6e6a261..ceceb64 100644 --- a/src/features/glsllintProvider.ts +++ b/src/features/glsllintProvider.ts @@ -242,7 +242,7 @@ export class GLSLLintingProvider { } private getShaderLiterals(literals: StringLiteral[]): StringLiteral[] { - const isShaderRegex = /main\s*\(.*\)\s*\{/gm; + const isShaderRegex = /main(.*|\s)\((.*|\s)\)/gm; const shaderLiterals = literals.filter((literal) => { // check if this literal is a shader diff --git a/test/test_shaders/.vscode/settings.json b/test/test_shaders/.vscode/settings.json index f76420b..a9c7f3e 100644 --- a/test/test_shaders/.vscode/settings.json +++ b/test/test_shaders/.vscode/settings.json @@ -1,15 +1,15 @@ { - "glsllint.additionalStageAssociations": { - ".fragment.fx": "frag", - ".vertex.fx": "vert" - }, - "glsllint.glslifyAutoOpenOnError": true, - "glsllint.glslifyOptions": { + // "glsllint.additionalStageAssociations": { + // ".fragment.fx": "frag", + // ".vertex.fx": "vert" + // }, + // "glsllint.glslifyAutoOpenOnError": true, + // "glsllint.glslifyOptions": { // "basedir": "G:\\src\\vscodeextensions\\vscode-glsllint\\test\\test_shaders\\GLSLIFY\\chunks" - }, + // }, // "glsllint.glslangValidatorArgs": "--target-env vulkan1.1", - "glsllint.glslifyUseCurrentFileAsBasedir": true, - "glsllint.linkShader": false, - "glsllint.glslangValidatorArgs": "-V", - "glsllint.fallBackStage": "comp" + // "glsllint.glslifyUseCurrentFileAsBasedir": true, + // "glsllint.linkShader": false, + // "glsllint.glslangValidatorArgs": "-V", + // "glsllint.fallBackStage": "comp" } diff --git a/test/test_shaders/GLSL_ES_3.00/pass_through.frag b/test/test_shaders/GLSL_ES_3.00/pass_through.frag new file mode 100644 index 0000000..2761c23 --- /dev/null +++ b/test/test_shaders/GLSL_ES_3.00/pass_through.frag @@ -0,0 +1,13 @@ +#version 300 es + +precision highp float; + +// input from vertex shader +in vec3 vColor; +out vec4 outPutColor; + + +void main() +{ + outPutColor = vec4(vec3(vColor), 1.0); +} diff --git a/test/test_shaders/GLSL_ES_3.00/pass_through.vert b/test/test_shaders/GLSL_ES_3.00/pass_through.vert new file mode 100644 index 0000000..77f76b7 --- /dev/null +++ b/test/test_shaders/GLSL_ES_3.00/pass_through.vert @@ -0,0 +1,14 @@ +#version 300 es + +uniform mat4 u_projectionMatrix; +uniform mat4 u_viewMatrix; +uniform mat4 u_modelMatrix; + +in vec3 a_position; + +out vec4 v_color; + +void main() { + v_color = vec4(1.0, 0.0, 0.0, 1.0); + gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * vec4( a_position, 1.0 ); +} diff --git a/test/test_shaders/STRINGLITERALS/script-pragmas.js b/test/test_shaders/STRINGLITERALS/script-pragmas.js index 1454557..ab388c1 100644 --- a/test/test_shaders/STRINGLITERALS/script-pragmas.js +++ b/test/test_shaders/STRINGLITERALS/script-pragmas.js @@ -32,7 +32,7 @@ function bar(param) { const another_shader = ` #version 460 core - #pragma vscode_glsllint_stage : frag + #pragma vscode_glsllint_stage: frag out vec4 FragColor; diff --git a/test/test_shaders/STRINGLITERALS/simple.js b/test/test_shaders/STRINGLITERALS/simple.js new file mode 100644 index 0000000..b381c1a --- /dev/null +++ b/test/test_shaders/STRINGLITERALS/simple.js @@ -0,0 +1,20 @@ +const vertexShaderSource = `#version 300 es +#pragma vscode_glsllint_stage: vert + +void main() +{ + gl_Position = vec4(0.0,0.0,0.0,1.0); +}`; + +const fregmentShderSource = ` +#version 300 es +#pragma vscode_glsllint_stage: frag +main() ERROR HERE FOR TRIGER THE VALIDATOR +{ + gl_FragColor = vec4(1.0,0.0,0.0,1.0); +}`; + +const c = document.querySelector('canvas'); +const gl = c.getContext('webgl2'); +const program = gl.createProgram(); +gl.useProgram(program); \ No newline at end of file