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

Suggestion: Select the span automatically based on cursor position for introduce local / constant #752

Closed
balajikris opened this issue Feb 20, 2015 · 4 comments
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings Resolution-Not Reproducible The described behavior could not be reproduced by developers
Milestone

Comments

@balajikris
Copy link
Member

Ported from TFS WorkItem: 1065670, originally filed by @shyamnamboodiripad


Repro Steps:

Currently, I if I want to invoke introduce local /constant refactoring on a multiline string literal, I am forced to select the entire string first. It would be nice if I could invoke the refactoring by simply placing cursor somewhere in the string and hitting ctrl + . 

Can't we figure out the minimum enclosing span for the current cursor position (i.e. expand to span of innermost node / expression containing the cursor) and offer refactorings as if the user had selected this span? I could also imagine this being useful for other expressions (date literals, expressions / method calls involving long identifiers etc.)

image

Looks like we do this already in some other refactorings? For example, if i select jsut 'String' in the following If statement, I am offered an extract method refactoring that extracts the entire 'typeof x isnot string' expression-

image

Revision History:

  1. Created By Shyam Namboodiripad (10/16/2014 11:22:37 PM)

  2. Edited By Kevin Pilch-Bisson (10/17/2014 10:03:24 AM)

Can you think about the UX here?

  1. Edited By Kevin Pilch-Bisson (2/20/2015 3:21:24 PM)

Yes, I think this is a good idea to help with our refactoring discoverability.  It may not fit in RTM though.  Can you port to GitHub.

@balajikris balajikris self-assigned this Feb 20, 2015
@balajikris balajikris added this to the 1.0 (stable) milestone Feb 20, 2015
@Pilchie Pilchie modified the milestones: 1.1, 1.0 (stable) May 1, 2015
@Pilchie
Copy link
Member

Pilchie commented May 1, 2015

Moving to 1.1.

@Pilchie Pilchie modified the milestones: 1.2, 1.1 Sep 15, 2015
@DustinCampbell DustinCampbell modified the milestones: 1.3, 1.2 Feb 23, 2016
@Pilchie Pilchie modified the milestones: 2.0 (RC), 1.3 May 27, 2016
@Pilchie Pilchie modified the milestones: 2.0 (Preview 5), 2.0 (RC) Sep 26, 2016
@Pilchie Pilchie modified the milestones: 2.1, 2.0 (RC) Nov 1, 2016
@Pilchie Pilchie modified the milestones: 15.1, 15.3 Mar 29, 2017
@Pilchie Pilchie modified the milestones: 15.3, Unknown Apr 10, 2017
@sharwell sharwell added Need Design Review The end user experience design needs to be reviewed and approved. and removed 0 - Backlog labels Nov 19, 2020
@ryanbrandenburg
Copy link
Contributor

Design Meeting Notes: Let's try this out with a service that lets the customer select an expression from a sub-list based on where their caret was when they invoked.

@sharwell
Copy link
Member

This refactoring will use IRefactoringHelpersService to provide the span information for a position:

Task<ImmutableArray<TSyntaxNode>> GetRelevantNodesAsync<TSyntaxNode>(Document document, TextSpan selection, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;

@sharwell sharwell added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Concept-Continuous Improvement IDE-CodeStyle Built-in analyzers, fixes, and refactorings and removed Need Design Review The end user experience design needs to be reviewed and approved. Feature Request labels Nov 30, 2020
@CyrusNajmabadi
Copy link
Member

Introduce constant is offered within a string literal:

image

@sharwell sharwell closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2023
@sharwell sharwell added the Resolution-Not Reproducible The described behavior could not be reproduced by developers label Feb 7, 2023
@sharwell sharwell moved this to Complete in IDE: Design review Aug 22, 2023
akhera99 added a commit that referenced this issue Oct 1, 2024
akhera99 added a commit that referenced this issue Oct 1, 2024
akhera99 added a commit that referenced this issue Oct 2, 2024
* Revert "Revert "Updates content exclusion for on-the-fly-docs (#75172)" (#752…" (#75324)

This reverts commit ba2f19a.

* fix error when merging

---------

Co-authored-by: Ankita Khera <40616383+akhera99@users.noreply.github.com>
Co-authored-by: Ankita Khera <ankitakhera@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings Resolution-Not Reproducible The described behavior could not be reproduced by developers
Projects
Archived in project
Development

No branches or pull requests

6 participants