Skip to content

Commit 164c601

Browse files
committed
fixed the qpbrowser, now creation and deletion work as intended.
1 parent 6f6c912 commit 164c601

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

plugin/quickpanel/qpbrowser.py

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
def qpi(text, details="", color=qpg.QP_COLOR_NONE, letter="", name="", hint="", prefix=""):
1212
return sublime.QuickPanelItem(text, details, annotation=hint, kind=(color, letter, name))
1313

14-
def show_qp(window, choices, on_done, placeholder=''):
14+
def show_qp(window, choices, on_done, placeholder='', keepopen=True):
1515
def _():
16-
flags = sublime.KEEP_OPEN_ON_FOCUS_LOST
16+
flags = sublime.KEEP_OPEN_ON_FOCUS_LOST if keepopen else 0
1717
window.show_quick_panel(choices, on_done, flags, placeholder=placeholder)
1818
sublime.set_timeout(_, 10)
1919

@@ -67,27 +67,6 @@ def _():
6767
sublime.set_timeout(_)
6868
logger.debug("exiting the server_broswer.")
6969

70-
# def select_workspace(self):
71-
# assert self.current_wid_selection
72-
# actions = [
73-
# qpi("Join", details=self.current_wid_selection, color=qpg.QP_COLOR_BLUISH, letter=qpg.QP_FORWARD),
74-
# # qpi("Join and open all",
75-
# # details="opens all buffer in the workspace",
76-
# # color=qpg.QP_COLOR_PINKISH, letter=qpg.QP_DETAILS),
77-
# qpi("Back", color=qpg.QP_COLOR_BLUISH, letter=qpg.QP_BACK)
78-
# ]
79-
# show_qp(self.window, actions, self.select_workspace_actions, self.qp_placeholder())
80-
81-
# def select_workspace_actions(self, index):
82-
# if index == -1:
83-
# return
84-
# elif index == 0:
85-
# self.window.run_command(
86-
# "codemp_join_workspace",
87-
# {"workspace_id": self.current_wid_selection})
88-
# elif index == 1:
89-
# self.run()
90-
9170

9271
def edit_server(self):
9372
actions = [
@@ -186,14 +165,12 @@ def edit_workspace_actions(self, index):
186165
self.run()
187166
elif index == 1:
188167
self.window.run_command(
189-
"codemp_leave_workspace",
190-
{"workspace_id": self.workspace_id})
168+
"codemp_leave_workspace", {"workspace_id": self.workspace_id})
191169
self.window.run_command(
192170
"codemp_browse_server", {})
193171
elif index == 2:
194172
self.window.run_command(
195-
"codemp_invite_to_workspace",
196-
{"workspace_id": self.workspace_id})
173+
"codemp_invite_to_workspace", {"workspace_id": self.workspace_id})
197174
elif index == 3:
198175
def create_buffer(name):
199176
self.window.run_command(
@@ -212,27 +189,30 @@ def create_buffer(name):
212189
def delete_buffer(index):
213190
if index == -1 or index == 0:
214191
self.edit_workspace()
192+
return
215193

216194
# same warning as the server browser. Check your indexed 3 times
217-
selected = self.entries[index+1]
195+
selected = self.entries[index]
218196
self.window.run_command(
219197
"codemp_delete_buffer",
220198
{
221199
"workspace_id": self.workspace_id,
222200
"buffer_id": selected.trigger
223201
})
224202

225-
def _():
226-
buffers = workspaces.lookupId(self.workspace_id).handle.fetch_buffers()
227-
QPWorkspaceBrowser(self.window, self.workspace_id, buffers.wait()).run()
228-
sublime.set_timeout(_)
203+
self.window.run_command(
204+
"codemp_browse_workspace", {"workspace_id": self.workspace_id})
229205

230206
if len(self.entries) < 2:
231207
sublime.message_dialog("The workspace is empty!")
232208
sublime.set_timeout(self.run, 10)
233209
else:
234-
show_qp(self.window, self.entries[1:], delete_buffer, self.qp_placeholder())
210+
selentries = self.entries
211+
selentries[0] = qpi("Back", color=qpg.QP_COLOR_CYANISH, letter=qpg.QP_BACK)
212+
show_qp(self.window, selentries, delete_buffer, self.qp_placeholder(), keepopen=False)
213+
235214

236215
elif index == 5:
237216
sublime.message_dialog("renaming is not yet implemented.")
238-
self.edit_workspace()
217+
self.edit_workspace()
218+
logger.debug("Exiting the workspace browser")

0 commit comments

Comments
 (0)