You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2021/12/09 16:19:30 UTC

[sling-whiteboard] 10/18: completions: don't suggest anything for unknown properties

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch feature/vscode-htl
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit dfe8fe5a495942fe45fc7d07b120ff36a9a28bd9
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Dec 9 11:37:43 2021 +0100

    completions: don't suggest anything for unknown properties
---
 vscode-htl/src/htlCompletionItemProvider.ts |  3 +++
 vscode-htl/src/test/suite/extension.test.ts | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/vscode-htl/src/htlCompletionItemProvider.ts b/vscode-htl/src/htlCompletionItemProvider.ts
index 347745c..8a605a2 100644
--- a/vscode-htl/src/htlCompletionItemProvider.ts
+++ b/vscode-htl/src/htlCompletionItemProvider.ts
@@ -39,6 +39,9 @@ export class HtlCompletionItemProvider implements vscode.CompletionItemProvider
             let matchingDefinition = completionProperties.find( e => e.name === completionCandidate );
             if ( matchingDefinition ) {
                 completionProperties = this.completionData.findPropertyCompletions(matchingDefinition.javaType);
+            } else {
+                completionProperties = [];
+                break;
             }
         }
 
diff --git a/vscode-htl/src/test/suite/extension.test.ts b/vscode-htl/src/test/suite/extension.test.ts
index c0ad357..d3473aa 100644
--- a/vscode-htl/src/test/suite/extension.test.ts
+++ b/vscode-htl/src/test/suite/extension.test.ts
@@ -92,4 +92,18 @@ suite('Extension Test Suite',  () => {
 		let completionVariables = completions?.map ( c => c.label.toString()).slice(0,5);
 		assert.deepStrictEqual(completionVariables?.sort(), ["children", "name", "parent", "path", "resourceType"]);
 	});
+
+	test('invalid completion test', () => {
+		let document = `
+			<html>
+				<body>
+					\${ request.foo. }
+				</body>
+			</html>
+		`;
+		let completions = completionProvider.provideCompletionItems0('${request.foo.', document);
+		// test a subset, otherwise it's too cumbersome
+		let completionVariables = completions?.map ( c => c.label.toString());
+		assert.deepStrictEqual(completionVariables?.sort(), []);
+	});
 });