René's URL Explorer Experiment


Title: TSServer: Refactor trigger reason · Issue #35096 · microsoft/TypeScript · GitHub

Open Graph Title: TSServer: Refactor trigger reason · Issue #35096 · microsoft/TypeScript

X Title: TSServer: Refactor trigger reason · Issue #35096 · microsoft/TypeScript

Description: Follow up on #34930 Problem VS Code lets user create keybindings for specific refactorings like extract constant. At present, TS Server does not know if refactorings are requested explicitly by the user using a keyboard shortcut or if th...

Open Graph Description: Follow up on #34930 Problem VS Code lets user create keybindings for specific refactorings like extract constant. At present, TS Server does not know if refactorings are requested explicitly by the...

X Description: Follow up on #34930 Problem VS Code lets user create keybindings for specific refactorings like extract constant. At present, TS Server does not know if refactorings are requested explicitly by the...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/35096

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TSServer: Refactor trigger reason","articleBody":"Follow up on #34930\r\n\r\n## Problem\r\nVS Code lets user create keybindings for specific refactorings like extract constant. At present, TS Server does not know if refactorings are requested explicitly by the user using a keyboard shortcut or if they are requested automatically when the user simply makes a selection in the current document.\r\n\r\nThis distinction is important for a few reasons brought up in #34930:\r\n\r\n- There are cases where we do not want the code action lightbulb to show up in VS Code but refactorings still should be availible if the user requests them\r\n- The TypeScript server could be less strict about the selection for manually requested refactorings. For example, if I request to `extract constant` with no selection, TS Server could assume that I want to extract the nearest expression.\r\n\r\n## Protocol Proposal\r\nIn the `getApplicableRefactors` request, add a new `triggerReason` field:\r\n\r\n```ts\r\ninterface GetApplicableRefactorsRequestArgs extends FileLocationOrRangeRequestArgs {\r\n    triggerReason?: RefactorTriggerReason;\r\n}\r\n```\r\n\r\nThe trigger reason would capture why the refactoring was requested:\r\n\r\n```ts\r\ntype RefactorTriggerReason = RefactorInvokedReason;\r\n\r\ninterface RefactorInvokedReason {\r\n    kind: 'invoked';\r\n}\r\n```\r\n\r\nAt the moment, I think we only need a single trigger reason: `invoked`. I have based this design around the existing server API for parameter hints.\r\n\r\n## How TS Server could use `triggerReason`\r\nAs a first step, when refactorings are explicitly invoked by the user, if the current selection is not extractable, we should automatically expand the selection for `extract constant` and `extract function` to nearest extractable expression.\r\n\r\n## Possible extension: hierarchal refactorings\r\nVS Code uses a hierarchal system to assign the class of code actions / refactorings. For example, `extract constant` has a [`CodeActionKind`](https://github.com/microsoft/vscode/blob/c408a2c02d78982b1f83819c587c02bb59af9f93/src/vs/vscode.d.ts#L1950) of `refactor.extract.constant`. Users can setup keybindings for `refactor.extract` (show all `extract` refactorings) or for `refactor.extract.constant` (show only the `extract constant` refactorings).\r\n\r\nWe should consider putting some form of hierarchical refactorings into the TS Server api as well. A few reasons this may be helpful:\r\n\r\n- If TS Server knows the type of refactorings being requested, it can only compute that subset of refactorings\r\n- In the future, we can specialize behavior for individual refactoring requests even more. For example, if a user explicitly requests `extract constant` refactorings for TS Server, we could show more than one expression around the current selection that can be extracted.\r\n\r\nTo support this in the server api, we would need to add a new another field on `RefactorInvokedReason`:\r\n\r\n```ts\r\ninterface RefactorInvokedReason {\r\n    kind: 'invoked';\r\n    refactorType?: RequestedRefactoringType;\r\n}\r\n```\r\n\r\nVS Code uses dotted string to represent a hierarchy of refactoring types (e.g. `\"refactor.extract.constant\"`). TS could also use this scheme. Or we could hardcode the hierarchy:\r\n\r\n```ts\r\nenum RequestedRefactoringType {\r\n    Refactor,\r\n    Refactor_Extract,\r\n    Refactor_Extract_Constant,\r\n    Refactor_Extract_Function,\r\n    ...\r\n}\r\n```\r\n","author":{"url":"https://github.com/mjbvz","@type":"Person","name":"mjbvz"},"datePublished":"2019-11-14T07:22:00Z","url":"https://github.com/microsoft/TypeScript/issues/35096"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3a7de9df-95a8-ebcc-e495-a26ea32cbfa4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAD72:2D2F2F:A35757:D4F1A5:6B00E400
html-safe-nonce1d836033bd2edf397028ffc717c6b4c2329b2482e79922b19d5f377c0b4be638
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDcyOjJEMkYyRjpBMzU3NTc6RDRGMUE1OjZCMDBFNDAwIiwidmlzaXRvcl9pZCI6Ijc3MDgwMjU5NTUwNjI3MDMxMDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac216586cfaddc1345685c538dd5fe012fa595b046fd9d01876be69dbbf568db3d
hovercard-subject-tagissue:522673366
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/35096/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a62337711cfa0ab378c1d63fab1f6d69d1523403e8f31de64adf18806e2a483e/microsoft/TypeScript/issues/35096
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a62337711cfa0ab378c1d63fab1f6d69d1523403e8f31de64adf18806e2a483e/microsoft/TypeScript/issues/35096
og:image:altFollow up on #34930 Problem VS Code lets user create keybindings for specific refactorings like extract constant. At present, TS Server does not know if refactorings are requested explicitly by the...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemjbvz
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/35096#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F35096
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F35096
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/35096
Reloadhttps://github.com/microsoft/TypeScript/issues/35096
Reloadhttps://github.com/microsoft/TypeScript/issues/35096
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests309 (309)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/35096
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/35096
#41975https://github.com/microsoft/TypeScript/pull/41975
TSServer: Refactor trigger reasonhttps://github.com/microsoft/TypeScript/issues/35096#top
#41975https://github.com/microsoft/TypeScript/pull/41975
https://github.com/PranavSenthilnathan
Domain: LS: Refactoringse.g. extract to constant or function, rename symbolhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20LS%3A%20Refactorings%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/mjbvz
Matt Bierner (mjbvz)https://github.com/mjbvz
on Nov 14, 2019https://github.com/microsoft/TypeScript/issues/35096#issue-522673366
#34930https://github.com/microsoft/TypeScript/issues/34930
#34930https://github.com/microsoft/TypeScript/issues/34930
CodeActionKindhttps://github.com/microsoft/vscode/blob/c408a2c02d78982b1f83819c587c02bb59af9f93/src/vs/vscode.d.ts#L1950
Andrew Branch (andrewbranch)https://github.com/andrewbranch
Domain: LS: Refactoringse.g. extract to constant or function, rename symbolhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20LS%3A%20Refactorings%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on Dec 10, 2019https://github.com/microsoft/TypeScript/issues/35096#event-2872455278
Matt Bierner (mjbvz)https://github.com/mjbvz
on Apr 14, 2020https://github.com/microsoft/TypeScript/issues/35096#event-3232875535
Add experimental trigger reason to ts server protocolhttps://github.com/microsoft/vscode/commit/b6c2ea092d86ac506489e2e5448a6094d0386db5
b6c2ea0https://github.com/microsoft/vscode/commit/b6c2ea092d86ac506489e2e5448a6094d0386db5
https://github.com/PranavSenthilnathan
Pranav Senthilnathan (PranavSenthilnathan)https://github.com/PranavSenthilnathan
on Jul 2, 2020https://github.com/microsoft/TypeScript/issues/35096#issuecomment-653254024
Mine Starks (@minestarks)https://github.com/minestarks
Mine Starks (minestarks)https://github.com/minestarks
Pranav Senthilnathan (PranavSenthilnathan)https://github.com/PranavSenthilnathan
on Sep 2, 2020https://github.com/microsoft/TypeScript/issues/35096#event-3722044409
https://github.com/jessetrinity
Jesse Trinity (jessetrinity)https://github.com/jessetrinity
on Oct 19, 2020https://github.com/microsoft/TypeScript/issues/35096#issuecomment-712412684
https://github.com/mjbvz
Matt Bierner (mjbvz)https://github.com/mjbvz
on Oct 29, 2020https://github.com/microsoft/TypeScript/issues/35096#issuecomment-719060734
Jesse Trinity (jessetrinity)https://github.com/jessetrinity
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#41975https://github.com/microsoft/TypeScript/pull/41975
on Dec 23, 2020https://github.com/microsoft/TypeScript/issues/35096#event-4145487545
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/35096
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/35096
Pranav Senthilnathan (PranavSenthilnathan)https://github.com/PranavSenthilnathan
Domain: LS: Refactoringse.g. extract to constant or function, rename symbolhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20LS%3A%20Refactorings%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.