Skip to content

Add a ctrl-alt shortcut one can hold to have all inline-hints show up.#48411

Merged
21 commits merged intodotnet:masterfrom
CyrusNajmabadi:toggleInlintHints
Oct 10, 2020
Merged

Add a ctrl-alt shortcut one can hold to have all inline-hints show up.#48411
21 commits merged intodotnet:masterfrom
CyrusNajmabadi:toggleInlintHints

Conversation

@CyrusNajmabadi
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Oct 7, 2020

UI for the feature looks like:

image

Looks like this:

inline hints

The core concept is htat while you're holding ctrl-alt, we show all hints. When you release, we go back to showing whatever hints your standard settings are for.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner October 7, 2020 20:55
@CyrusNajmabadi CyrusNajmabadi requested review from a team, jasonmalinowski and olegtk October 7, 2020 20:55
@CyrusNajmabadi
Copy link
Contributor Author

Tagging @olegtk as i want to make sure we're being a good citizen here wrt intercepting key strokes.

@CyrusNajmabadi CyrusNajmabadi force-pushed the toggleInlintHints branch 2 times, most recently from fdf53c9 to 1d86d22 Compare October 7, 2020 20:56
private static void Toggle(Workspace workspace, bool on)
{
// No need to do anything if we're already in the requested state
var state = workspace.Options.GetOption(InlineHintsOptions.DisplayAllOverride);
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to disable this whole processor if this option is on? And enable when it changes? This is typing code path, so ideally there should be as less work done on UI thread as possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm not certain. is there a way to disable a processor? note: i want to be careful that if the option changes that we don't get stuck with things on the screen.

Also, on every keystroke we're already doing this sort of work in other features (i.e. tracking what you type for things like rename-tracking, completion, etc.). So i'm not particularly concerned here on perf.

Comment on lines +62 to +71
private Document? GetDocument()
{
var document =
_view.BufferGraph.GetTextBuffers(b => true)
.Select(b => b.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges())
.WhereNotNull()
.FirstOrDefault();

return document;
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to check this? I can't really come up with a case where our content type is set but we don't have a document in a way we'd really care about here. More a "less code is better" here.

Copy link
Member

Choose a reason for hiding this comment

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

(general concern also being as this PR stands this is running on every key event and every modifier...)


// We can only enter the on-state if the user has the ctrl-alt feature enabled. We can always enter the
// off state though.
on = on && _globalOptionService.GetOption(InlineHintsOptions.DisplayAllHintsWhilePressingCtrlAlt, document.Project.Language);
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to happen before you've compared "on" to "state"?

@jasonmalinowski
Copy link
Member

@CyrusNajmabadi things look good other than some of stuff in the key processor but I think that's it. I guess I see now we're grabbing the document because we need it for the per-language option. Should we just make the Ctrl+Alt stuff be a single option that's shared between the languages? If you've got a VB file open on one monitor and a C# one open on the other, do you want which language your focus is on to dictate?

@jasonmalinowski
Copy link
Member

(I was originally thinking the code could be deleted but now you've got me thinking questions with no clear opinion of an answer here.)

@CyrusNajmabadi
Copy link
Contributor Author

Yup, being language specific isn't beneficial here. removing that.

@ghost
Copy link

ghost commented Oct 10, 2020

Hello @CyrusNajmabadi!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit eaeafbf into dotnet:master Oct 10, 2020
@ghost ghost added this to the Next milestone Oct 10, 2020
@CyrusNajmabadi CyrusNajmabadi deleted the toggleInlintHints branch October 10, 2020 14:41
@Cosifne Cosifne modified the milestones: Next, 16.9.P1 Oct 12, 2020
This pull request was closed.
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.

6 participants