Skip to content

Commit 91bf9c5

Browse files
committed
show the first file content of gist
1 parent c27eca9 commit 91bf9c5

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.gradle/
2+
.idea/
3+
build/

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Fri Jan 03 09:29:20 CST 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
2+
distributionUrl=https\://downloads.gradle-dn.com/distributions/gradle-6.8.3-bin.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists

src/main/java/com/chuntung/plugin/gistsnippet/view/InsertGistDialog.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,16 @@ private void initYoursPane(List<GithubAccount> accountList) {
319319
}
320320

321321
private void onSelect(TreeSelectionEvent e) {
322-
DefaultMutableTreeNode selected = null;
323322
TreePath treePath = e.getNewLeadSelectionPath();
324-
if (treePath != null) {
325-
selected = (DefaultMutableTreeNode) treePath.getLastPathComponent();
323+
if (treePath == null || treePath.getLastPathComponent() == null) {
324+
return;
326325
}
327-
if (selected != null && selected.isLeaf() && selected.getUserObject() instanceof GistFileDTO) {
326+
DefaultMutableTreeNode selected = (DefaultMutableTreeNode) treePath.getLastPathComponent();
327+
// show the first file when gist item is selected
328+
if (selected.getUserObject() instanceof SnippetNodeDTO && selected.getChildCount() > 0) {
329+
selected = (DefaultMutableTreeNode) selected.getFirstChild();
330+
}
331+
if (selected.getUserObject() instanceof GistFileDTO) {
328332
// show file content
329333
GistFileDTO gistFileDTO = getUserObject(selected);
330334
showingFileUrl = gistFileDTO.getRawUrl();

0 commit comments

Comments
 (0)