Skip to content

Conversation

@ericsciple
Copy link
Collaborator

No description provided.

// Get action scaffolding snippets if applicable
let actionSnippets: CompletionItem[] = [];
if (isAction && config?.featureFlags?.isEnabled("actionScaffoldingSnippets")) {
actionSnippets = getActionScaffoldingSnippets(parsedTemplate.value, path, position, replaceRange);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved down because it needs replaceRange

@ericsciple ericsciple force-pushed the users/ericsciple/26-01-range branch from b6b084c to af7f08e Compare January 21, 2026 21:33
path: TemplateToken[],
position: Position
position: Position,
replaceRange?: Range
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plumbing replaceRange. Refer languageservice/src/complete.ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is consistent with now non-snippet completion works

@ericsciple ericsciple marked this pull request as ready for review January 21, 2026 21:38
@ericsciple ericsciple requested a review from a team as a code owner January 21, 2026 21:38
Copilot AI review requested due to automatic review settings January 21, 2026 21:38
@ericsciple ericsciple changed the title Fix scaffolding snippets to replace typed text instead of inserting Fix action.yml snippets to replace typed text instead of inserting Jan 21, 2026
@ericsciple ericsciple merged commit 74d69b2 into main Jan 21, 2026
11 checks passed
@ericsciple ericsciple deleted the users/ericsciple/26-01-range branch January 21, 2026 21:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes action scaffolding snippet completions so selecting a snippet replaces the user’s already-typed text (prefix) instead of inserting the snippet after it.

Changes:

  • Compute and pass a replaceRange into action scaffolding snippet generation.
  • Update scaffolding snippet textEdit to use TextEdit.replace(...) when a replace range is available.
  • Add tests asserting scaffolding snippets replace typed prefixes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
languageservice/src/complete.ts Moves snippet generation to after replaceRange calculation and passes replaceRange into scaffolding snippet creation.
languageservice/src/complete-action.ts Extends scaffolding snippet helpers to accept an optional replaceRange and uses it to create replace-vs-insert textEdits.
languageservice/src/complete-action.test.ts Adds test coverage ensuring scaffolding snippets replace typed prefixes and handle empty-file scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const [doc, position] = createActionDocument(`|`);
const completions = await complete(doc, position, scaffoldingConfig);

const compositeSnippet = completions.find(c => c.label === "Composite Action");
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test, compositeSnippet isn't asserted to exist before dereferencing textEdit.range, so a missing snippet will fail with a TypeError rather than a clear expectation failure. Add an explicit expect(compositeSnippet).toBeDefined() (or assert on compositeSnippet?.textEdit) before reading textEdit.range.* to improve debuggability.

Suggested change
const compositeSnippet = completions.find(c => c.label === "Composite Action");
const compositeSnippet = completions.find(c => c.label === "Composite Action");
expect(compositeSnippet).toBeDefined();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants