Merge pull request #10053 from prometheus/bugfix/codemirror

Fix autocompletion when expr is empty in codemirror
This commit is contained in:
Julius Volz 2021-12-20 21:59:56 +01:00 committed by GitHub
commit 257a9c161b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 15 deletions

View file

@ -41,7 +41,8 @@
"@codemirror/lint": "^0.19.3", "@codemirror/lint": "^0.19.3",
"@codemirror/state": "^0.19.6", "@codemirror/state": "^0.19.6",
"@codemirror/view": "^0.19.27", "@codemirror/view": "^0.19.27",
"@lezer/common": "^0.15.10", "@lezer/common": "^0.15.11",
"@lezer/lr": "^0.15.5",
"@lezer/generator": "^0.15.2", "@lezer/generator": "^0.15.2",
"@types/chai": "^4.2.22", "@types/chai": "^4.2.22",
"@types/lru-cache": "^5.1.1", "@types/lru-cache": "^5.1.1",
@ -73,7 +74,7 @@
"@codemirror/lint": "^0.19.3", "@codemirror/lint": "^0.19.3",
"@codemirror/state": "^0.19.6", "@codemirror/state": "^0.19.6",
"@codemirror/view": "^0.19.27", "@codemirror/view": "^0.19.27",
"@lezer/common": "^0.15.10" "@lezer/common": "^0.15.11"
}, },
"prettier": { "prettier": {
"singleQuote": true, "singleQuote": true,

View file

@ -342,7 +342,7 @@ export function analyzeCompletion(state: EditorState, node: SyntaxNode): Context
} }
break; break;
case PromQL: case PromQL:
if (!node.firstChild) { if (node.firstChild !== null && node.firstChild.type.id === 0) {
// this situation can happen when there is nothing in the text area and the user is explicitly triggering the autocompletion (with ctrl + space) // this situation can happen when there is nothing in the text area and the user is explicitly triggering the autocompletion (with ctrl + space)
result.push( result.push(
{ kind: ContextKind.MetricName, metricName: '' }, { kind: ContextKind.MetricName, metricName: '' },

View file

@ -27,8 +27,9 @@
"@codemirror/lint": "^0.19.3", "@codemirror/lint": "^0.19.3",
"@codemirror/state": "^0.19.6", "@codemirror/state": "^0.19.6",
"@codemirror/view": "^0.19.27", "@codemirror/view": "^0.19.27",
"@lezer/common": "^0.15.10", "@lezer/common": "^0.15.11",
"@lezer/generator": "^0.15.2", "@lezer/generator": "^0.15.2",
"@lezer/lr": "^0.15.5",
"@types/chai": "^4.2.22", "@types/chai": "^4.2.22",
"@types/lru-cache": "^5.1.1", "@types/lru-cache": "^5.1.1",
"@types/mocha": "^9.0.0", "@types/mocha": "^9.0.0",
@ -62,7 +63,7 @@
"@codemirror/lint": "^0.19.3", "@codemirror/lint": "^0.19.3",
"@codemirror/state": "^0.19.6", "@codemirror/state": "^0.19.6",
"@codemirror/view": "^0.19.27", "@codemirror/view": "^0.19.27",
"@lezer/common": "^0.15.10" "@lezer/common": "^0.15.11"
} }
}, },
"module/codemirror-promql/node_modules/@eslint/eslintrc": { "module/codemirror-promql/node_modules/@eslint/eslintrc": {
@ -1567,9 +1568,9 @@
} }
}, },
"node_modules/@lezer/common": { "node_modules/@lezer/common": {
"version": "0.15.10", "version": "0.15.11",
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-0.15.10.tgz", "resolved": "https://registry.npmjs.org/@lezer/common/-/common-0.15.11.tgz",
"integrity": "sha512-vlr+be73zTDoQBIknBVOh/633tmbQcjxUu9PIeVeYESeBK3V6TuBW96RRFg93Y2cyK9lglz241gOgSn452HFvA==" "integrity": "sha512-vv0nSdIaVCRcJ8rPuDdsrNVfBOYe/4Szr/LhF929XyDmBndLDuWiCCHooGlGlJfzELyO608AyDhVsuX/ZG36NA=="
}, },
"node_modules/@lezer/generator": { "node_modules/@lezer/generator": {
"version": "0.15.2", "version": "0.15.2",
@ -1584,8 +1585,9 @@
} }
}, },
"node_modules/@lezer/lr": { "node_modules/@lezer/lr": {
"version": "0.15.2", "version": "0.15.5",
"license": "MIT", "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-0.15.5.tgz",
"integrity": "sha512-DEcLyhdmBxD1foQe7RegLrSlfS/XaTMGLkO5evkzHWAQKh/JnFWp7j7iNB7s2EpxzRrBCh0U+W7JDCeFhv2mng==",
"dependencies": { "dependencies": {
"@lezer/common": "^0.15.0" "@lezer/common": "^0.15.0"
} }
@ -27644,9 +27646,9 @@
} }
}, },
"@lezer/common": { "@lezer/common": {
"version": "0.15.10", "version": "0.15.11",
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-0.15.10.tgz", "resolved": "https://registry.npmjs.org/@lezer/common/-/common-0.15.11.tgz",
"integrity": "sha512-vlr+be73zTDoQBIknBVOh/633tmbQcjxUu9PIeVeYESeBK3V6TuBW96RRFg93Y2cyK9lglz241gOgSn452HFvA==" "integrity": "sha512-vv0nSdIaVCRcJ8rPuDdsrNVfBOYe/4Szr/LhF929XyDmBndLDuWiCCHooGlGlJfzELyO608AyDhVsuX/ZG36NA=="
}, },
"@lezer/generator": { "@lezer/generator": {
"version": "0.15.2", "version": "0.15.2",
@ -27657,7 +27659,9 @@
} }
}, },
"@lezer/lr": { "@lezer/lr": {
"version": "0.15.2", "version": "0.15.5",
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-0.15.5.tgz",
"integrity": "sha512-DEcLyhdmBxD1foQe7RegLrSlfS/XaTMGLkO5evkzHWAQKh/JnFWp7j7iNB7s2EpxzRrBCh0U+W7JDCeFhv2mng==",
"requires": { "requires": {
"@lezer/common": "^0.15.0" "@lezer/common": "^0.15.0"
} }
@ -28431,8 +28435,9 @@
"@codemirror/lint": "^0.19.3", "@codemirror/lint": "^0.19.3",
"@codemirror/state": "^0.19.6", "@codemirror/state": "^0.19.6",
"@codemirror/view": "^0.19.27", "@codemirror/view": "^0.19.27",
"@lezer/common": "^0.15.10", "@lezer/common": "^0.15.11",
"@lezer/generator": "^0.15.2", "@lezer/generator": "^0.15.2",
"@lezer/lr": "^0.15.5",
"@types/chai": "^4.2.22", "@types/chai": "^4.2.22",
"@types/lru-cache": "^5.1.1", "@types/lru-cache": "^5.1.1",
"@types/mocha": "^9.0.0", "@types/mocha": "^9.0.0",