Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support completions inside object spread #14000

Merged
merged 1 commit into from
May 3, 2024
Merged

Conversation

anthony-c-martin
Copy link
Member

@anthony-c-martin anthony-c-martin commented May 3, 2024

This would allow completions for an outer object type within a spread - e.g. foo and bar should be offered in the following cursor location:

type myType = {
  foo: string
  bar: string
}
output foo myType = {
  ...{ | }
  bar: 'bar'
}

Raised by @slavizh on the community call.

Microsoft Reviewers: Open in CodeFlow

Copy link
Contributor

github-actions bot commented May 3, 2024

Test this change out locally with the following install scripts (Action run 8941982183)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 8941982183
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 8941982183"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 8941982183
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 8941982183"

Copy link
Contributor

github-actions bot commented May 3, 2024

Test Results

    65 files   -     34      65 suites   - 34   22m 20s ⏱️ - 10m 6s
10 877 tests  -     19  10 876 ✅  -     19  1 💤 ±0  0 ❌ ±0 
25 632 runs   - 12 836  25 630 ✅  - 12 835  2 💤  - 1  0 ❌ ±0 

Results for commit 91fe821. ± Comparison against base commit cfc27df.

♻️ This comment has been updated with latest results.

@anthony-c-martin anthony-c-martin force-pushed the ant/spread_val branch 4 times, most recently from e7c9c9e to e200827 Compare May 3, 2024 10:51
Comment on lines +1322 to +1328
return (nodeBefore, nodeAfter) switch {
(Token { Type: TokenType.NewLine }, {} after) when after == objectSyntax.CloseBrace => true,
(Token { Type: TokenType.Comma }, {} after) when after == objectSyntax.CloseBrace => true,
({} before, {} after) when before == objectSyntax.OpenBrace && after == objectSyntax.CloseBrace => true,
({} before, Token { Type: TokenType.NewLine }) when before == objectSyntax.OpenBrace => true,
(Token { Type: TokenType.NewLine }, Token { Type: TokenType.NewLine }) => true,
_ => false,
Copy link
Member Author

@anthony-c-martin anthony-c-martin May 3, 2024

Choose a reason for hiding this comment

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

These changes are not strictly necessary for spread completions generally, but I noticed we're missing completions for single-line objects - e.g. the following scenarios:

foo = { | }
foo = {|}
foo = {|
  bar: 'bar'
}
foo = {bar:'bar',|}

@anthony-c-martin anthony-c-martin merged commit add04e6 into main May 3, 2024
44 checks passed
@anthony-c-martin anthony-c-martin deleted the ant/spread_val branch May 3, 2024 16:26
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.

None yet

2 participants