Skip to content

feat(lsp): complete closing triple-quoted strings - #4737

Open
mangeshraut712 wants to merge 1 commit into
facebook:mainfrom
mangeshraut712:feat/triple-quoted-string-completions
Open

feat(lsp): complete closing triple-quoted strings#4737
mangeshraut712 wants to merge 1 commit into
facebook:mainfrom
mangeshraut712:feat/triple-quoted-string-completions

Conversation

@mangeshraut712

Copy link
Copy Markdown
Contributor

Summary

Fixes #4346

When the cursor is immediately after one, two, or three " / ' quotes, offer a completion that turns them into a closed triple-quoted string (the ty behavior).

  • 1–2 quotes: replace the run with """…""" (snippet $0 between the pair when the client supports snippets).
  • 3 quotes: insert the closer after the cursor ($0""" with snippets).
  • Skip if the next characters are already a matching """ / '''.
  • Skip quotes attached to an identifier (foo"), but still fire after string prefixes (f""", r""", …).

AI usage: an assistant drafted the completion helper and tests; I reviewed the LSP edit ranges, prefix handling, and test cursors.

Test Plan

cargo test -p pyrefly --lib -- completion_closes_triple -- completion_expands_partial -- completion_skips_triple -- completion_skips_quotes -- completion_closes_prefixed

All five new tests passed.

Offer a snippet (or plain text) completion that expands a 1–2 quote
run into a triple-quoted pair, or inserts the closer after an opening
""". Matches the ty completion request in facebook#4346.
@meta-cla

meta-cla Bot commented Aug 30, 2026

Copy link
Copy Markdown

Hi @mangeshraut712!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Aug 30, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide completions for triple quoted strings

2 participants