Skip to content

Commit 492cf24

Browse files
committed
rename: use default command instead of custom one
The slight problem is that if we don't disable the default command, then it shows up before the `New` command, which isn't right. So, instead, we enable the default (rename_path), but hide it (is_visible() -> False). Then, we create our own little command (fm_rename_path) that calls rename_path. Like this, we control where fm_rename_path shows up in the context menu. File Manager: Rename has been removed from the command palette (use Rename File). fm_rename now prints a deprecation warning. We don't use Python's warning module because warnings aren't enabled by default, and I don't want to change the defaults for everyone. ref #49
1 parent 5f1b64c commit 492cf24

5 files changed

Lines changed: 15 additions & 9 deletions

File tree

FileManager.sublime-commands

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
"caption": "File Manager: New File",
44
"command": "fm_create"
55
},
6-
{
7-
"caption": "File Manager: Rename",
8-
"command": "fm_rename"
9-
},
106
{
117
"caption": "File Manager: Move",
128
"command": "fm_move"

FileManager.sublime-settings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"show_open_in_browser_command": true,
109109
"show_open_terminal_command": true,
110110
"show_rename_command": true,
111+
"show_rename_path_command": true,
111112
"show_create_from_selection_command": true,
112113
"show_open_all_command": true,
113114

Side Bar.sublime-menu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{
3535
"caption": "Rename...",
3636
"mnemonic": "R",
37-
"command": "fm_rename",
37+
"command": "fm_rename_path",
3838
"args": {
3939
"paths": []
4040
}

commands/rename.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@
66
from .appcommand import AppCommand
77

88

9+
class FmRenamePathCommand(AppCommand):
10+
def run(self, paths):
11+
sublime.active_window().run_command("rename_path", {"paths": paths})
12+
13+
914
class FmRenameCommand(AppCommand):
1015
def run(self, paths=None):
16+
print(
17+
"fm_rename has been deprecated. It doesn't provide any more useful feature "
18+
"than the default command. You should use rename_path (for a "
19+
"file or a folder) or rename_file (for a file) instead."
20+
)
21+
sublime.status_message("fm_rename has been deprecated (see console)")
1122
self.settings = get_settings()
1223
self.window = get_window()
1324
self.view = self.window.active_view()

prevent_default.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sublime_plugin
2+
from Default.side_bar import RenamePathCommand
23

34

45
class NewFileAtCommand(sublime_plugin.WindowCommand):
@@ -33,13 +34,10 @@ def is_enabled(self):
3334
return False
3435

3536

36-
class RenamePathCommand(sublime_plugin.WindowCommand):
37+
class RenamePathCommand(RenamePathCommand):
3738
def is_visible(self):
3839
return False
3940

40-
def is_enabled(self):
41-
return False
42-
4341

4442
class FindInFolderCommand(sublime_plugin.WindowCommand):
4543
def is_visible(self):

0 commit comments

Comments
 (0)