Skip to content

Commit

Permalink
Fix completion when the schema node cannot be resolved
Browse files Browse the repository at this point in the history
Due to a partially defined property under the cursor
  • Loading branch information
davelopez committed Jun 2, 2024
1 parent c471395 commit 0ff7b52
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server/gx-workflow-ls-format2/src/services/completionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ export class GxFormat2CompletionService {
};
const textBuffer = new TextBuffer(textDocument);
const offset = textBuffer.getOffsetAt(position);
const node = nodeManager.getNodeFromOffset(offset);
let node = nodeManager.getNodeFromOffset(offset);

const existing = nodeManager.getDeclaredPropertyNames(node);
const nodePath = nodeManager.getPathFromNode(node);
const schemaNode = this.schemaNodeResolver.resolveSchemaContext(nodePath);
let schemaNode = this.schemaNodeResolver.resolveSchemaContext(nodePath);
if (schemaNode === undefined) {
// Try parent node
node = node?.parent;
const parentPath = nodePath.slice(0, -1);
const parentNode = this.schemaNodeResolver.resolveSchemaContext(parentPath);
schemaNode = parentNode;
}
if (schemaNode) {
const existing = nodeManager.getDeclaredPropertyNames(node);
result.items = this.getProposedItems(schemaNode, textBuffer, existing, offset);
}
return Promise.resolve(result);
Expand Down

0 comments on commit 0ff7b52

Please sign in to comment.