@@ -26,7 +26,7 @@ class App {
26
26
constructor ( ) {
27
27
/** @type Array<Selection> */
28
28
this . selections = new Array ( )
29
-
29
+
30
30
/** @type string */
31
31
this . parent = ""
32
32
@@ -52,21 +52,27 @@ class App {
52
52
53
53
/**
54
54
* Queries the plugin for results from this input
55
- *
56
- * @param {string } input
55
+ *
56
+ * @param {string } input
57
57
*/
58
58
query ( input ) {
59
59
if ( input . startsWith ( '~' ) ) {
60
60
input = GLib . get_home_dir ( ) + input . substr ( 1 )
61
61
}
62
62
63
63
this . last_query = input
64
+
65
+ // Add `/` to query if the input is a directory
66
+ this . last_query = ( ! input . endsWith ( '/' ) && Gio . file_new_for_path ( input ) . query_file_type ( 0 , null ) === 2 )
67
+ ? input + '/'
68
+ : input
69
+
64
70
this . selections . splice ( 0 )
65
- this . parent = GLib . path_get_dirname ( input )
71
+ this . parent = GLib . path_get_dirname ( this . last_query )
66
72
67
73
/** @type string */
68
- let base = GLib . path_get_basename ( input )
69
-
74
+ let base = GLib . path_get_basename ( this . last_query )
75
+
70
76
const show_hidden = base . startsWith ( '.' )
71
77
72
78
if ( this . parent . endsWith ( base ) ) base = ""
@@ -85,7 +91,7 @@ class App {
85
91
continue
86
92
}
87
93
88
- if ( ! show_hidden && name . startsWith ( '.' ) ) continue
94
+ if ( ! show_hidden && name . startsWith ( '.' ) ) continue
89
95
90
96
const content_type = entry . get_content_type ( )
91
97
const directory = entry . get_file_type ( ) === 2
@@ -106,7 +112,7 @@ class App {
106
112
const a_name = a . name . toLowerCase ( )
107
113
const b_name = b . name . toLowerCase ( )
108
114
109
- const pattern_lower = input . toLowerCase ( )
115
+ const pattern_lower = this . last_query . toLowerCase ( )
110
116
111
117
const a_includes = a_name . includes ( pattern_lower )
112
118
const b_includes = b_name . includes ( pattern_lower )
@@ -133,7 +139,7 @@ class App {
133
139
134
140
/**
135
141
* Applies an option that the user selected
136
- *
142
+ *
137
143
* @param {number } id
138
144
*/
139
145
submit ( id ) {
@@ -153,17 +159,17 @@ class App {
153
159
154
160
/**
155
161
* Sends message back to Pop Shell
156
- *
157
- * @param {Object } object
162
+ *
163
+ * @param {Object } object
158
164
*/
159
165
send ( object ) {
160
166
STDOUT . write_bytes ( new GLib . Bytes ( JSON . stringify ( object ) + "\n" ) , null )
161
167
}
162
168
}
163
169
164
170
/**
165
- *
166
- * @param {string } parent
171
+ *
172
+ * @param {string } parent
167
173
* @param {Selection } selection
168
174
* @returns {string }
169
175
*/
0 commit comments