Skip to content

Commit 241b3d1

Browse files
committed
perf(merge setting): 优化合并 feat/setting 后的代码
1 parent 18e6b26 commit 241b3d1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

main.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ def run(self, edit: sublime.Edit):
204204
commands_count = SETTINGS['history_count']
205205
else:
206206
commands_count = len(HISTORY.data)
207+
207208
commands_list = HISTORY.data[0:commands_count]
209+
print("commands_count: ", commands_count)
208210

209211
selection_with_index = [ f'{index + 1}. {HISTORY.data[index]}' for index in range(len(commands_list))]
210212

@@ -284,21 +286,22 @@ def run_command(self, user_input:str, panel_name:str=None):
284286
cwd = os.path.dirname(self.view.file_name())
285287

286288
# run in new shell window
289+
run_with_new_window = False
287290
if user_input[0][0] in RUN_IN_NEW_WINDOW_PREFIX:
288291
if user_input[0][0] == ':':
289-
pause = True
292+
run_with_new_window = True
290293

291294
if user_input[0][0] == '$':
292-
pause = 5
295+
run_with_new_window = 5
293296

294297
commands = str(user_input[1:]).split(' ')
295-
shell.run_command(commands, shell=True, pause=pause, cwd=cwd)
298+
shell.run_command(commands, shell=bool(run_with_new_window), pause=run_with_new_window, cwd=cwd)
296299

297300
return
298301

299302
# running in sublime exec
300303
commands = str(user_input).split(' ')
301-
res = shell.run_command(commands, shell=False, pause=False, cwd=cwd)
304+
res = shell.run_command(commands, shell=run_with_new_window, pause=run_with_new_window, cwd=cwd)
302305

303306
if res['success']:
304307
command_res = res['res']

0 commit comments

Comments
 (0)