Create gist from Visual Studio #39
+1
It's not mission-critical, but I'm sure I feel sad at least twice a week because I have to open the browser and open the site and copy-paste stuff and then copy link. Oh god, it's even more painful now when I described that.
I think we have some code for doing this laying around even. We had implemented this in GitHub for Windows and then removed it because it was so undiscoverable. We relied on a keyboard shortcut.
Would would be nice is if we could inject ourselves in the context menu when you select a snippet of text in the Visual Studio editor. I'm not sure if that's possible.
Alternatively, we could add a menu to Create Gist from Selection. We should think through the user experience before setting to work on it.
How often do you think you'd use that?
Regulary, but not very often.
We should think through the user experience before setting to work on it.
Both options are fine for me as long as I can reach them with keyboard. Context menu may be more intuitive though.
Notes for help-wanted label
This is a nice small feature that could be very interesting for someone wanting to contribute to the project! If you'd like to tackle this (hurrah!), here are the steps that should go into making it happen:
-
Define the User Experience for the feature
- How would users go about using it? Context menus? Keyboard shortcuts? Action tags? What is the discoverability path for it?
- Mockup the flow of the experience - what happens from the point where a user wants to create a gist to the point where the action is completed. Does it popup a window? Show a notification? A dialog? What options would there be for creating the gist, if any? Is it a one-click thing or a more complex flow? Does the feature need user settings or configurations?
-
Implement!
- Fork and create a branch for the feature, and create a PR for the branch. You build the PR over time as you implement things, and practical implementation discussions happen there!
-
🚢
Thinking about the process to create a gist from code in the editor
Select code
Ctrl + C
Ctrl + Tab (until browser)
Ctrl + T
Start typing 'gist' and hit return when http://gist.github.com appears
Name gist and hit tab
Ctrl + V
Review code doesn't contain sensitive information
Mouse to 'Create secret gist' or 'Create public gist'
Select URL
Ctrl + C
Ctrl + Tab (until in email, IM or other communication tool)
Ctrl + V
Some observations
- There is definitely a need for the text been gist-ed to be reviewed before been sent to GitHub.
- Code and text is leaving the users control. There must be a way to abort in the event of incorrect invocation.
- On creating a gist via the API you need to specify if it is public or private. Also any future redaction by default will remain in the history of the gist!
- Code and text is leaving the users control. There must be a way to abort in the event of incorrect invocation.
- Users are using gist to share something
- The last point should make it simple to get the URL of the gist
- What about services like bl.ocks and Neo4j GraphGist which auto wrap gists into a more useful formats. Should users be able to enable/add these types of third party services?
Anyone want to add any more observations/comments before starting on the new experience?
Would be cool to have as few clicks as possible. I believe it's OK if in first version it just creates private gists without asking. It's the main reason why you need such kind of extension — most of the time you just want to show the code to teammate(s), not to create some useful peace of wisdom.
I agree, preview is a must.
So, to me it looks like this:
- Highlight the code.
- Click/press «Gist it».
- Preview (right in the editor, probably).
- «The gist url was copied to the clipboard» balloon appears.
For a first version, it's fine (and preferable!) if the experience be kept as simple as possible. We can always add more features and options later.
- Highlight the code.
- Click/press «Gist it».
- Preview (right in the editor, probably).
- «The gist url was copied to the clipboard» balloon appears.
This feels like a good first approach.
Anyone want to add any more observations/comments before starting on the new experience?
I looked at how integration with Gist implemented in Intellij IDEA.
How would users go about using it? Context menus? Keyboard shortcuts? Action tags? What is the discoverability path for it?
I think it is true that many people use mouse for highlighting. So the context menu which opens by right click looks good for "Gist it" command. Intellij IDEA implements Gist support in such way so this is time-proven.
About preview. I already know and I see what code will be in the gist -- it is highlighted by me a moment ago. As for me the preview is not necessary. Also, IDEA doesn't have it and there are no requests for it.
This feels like a good first approach.
Yeah
I actually tried to do this one a while back and couldn't get past adding the VSCT entry :D
If anyone wants to tackle this and needs a starting point, I committed some old code I had laying around. It shows you how to add the context menu item and then retrieve the selected text (or whole file) from the code editor.
After that you would need to hook into the existing GHVS infrastructure to submit the gist, as well as any UI you want to display.
https://github.com/jpobst/GistPaste/blob/master/GistPaste/PasteToGistCommand.cs
BTW, there's already code in place to handle menus and commands. The package adds context menus in the "Connections" area like this - https://github.com/github/VisualStudio/blob/master/src/GitHub.VisualStudio/GitHubPackage.cs#L51
Is it possible to create gist from selected lines with this extension?