Skip to content

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

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

mangeshraut712 wants to merge 3 commits 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.

@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!

@github-actions
github-actions Bot requested a review from samwgoldman August 31, 2026 09:26
@cursor
cursor Bot force-pushed the feat/triple-quoted-string-completions branch from e7b7748 to 55ebe4a Compare September 6, 2026 15:03
@github-actions github-actions Bot added size/l and removed size/l labels Sep 6, 2026
@meta-codesync

meta-codesync Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D119010817. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions github-actions Bot added size/l and removed size/l labels Sep 6, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/l and removed size/l labels Sep 11, 2026
@github-actions

This comment has been minimized.

@cursor
cursor Bot force-pushed the feat/triple-quoted-string-completions branch from 3bb0928 to dd4e429 Compare September 21, 2026 05:18
@github-actions github-actions Bot added size/l and removed size/l labels Sep 21, 2026
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.
A one- or two-quote run is already an open string, so expanding it
into a triple-quoted snippet stole Literal, dict-key, and kwarg
completions. Offer the closer only after """ / '''.
@cursor
cursor Bot force-pushed the feat/triple-quoted-string-completions branch from dd4e429 to cff85b2 Compare September 22, 2026 05:15
@github-actions github-actions Bot added size/l and removed size/l labels Sep 22, 2026
@github-actions github-actions Bot added size/l and removed size/l labels Sep 23, 2026
@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

This branch has not been deployed

No deployments
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