Skip to content

Commit

Permalink
rename: use default command instead of custom one
Browse files Browse the repository at this point in the history
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
  • Loading branch information
math2001 committed Jan 18, 2020
1 parent 5f1b64c commit 492cf24
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 0 additions & 4 deletions FileManager.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"caption": "File Manager: New File",
"command": "fm_create"
},
{
"caption": "File Manager: Rename",
"command": "fm_rename"
},
{
"caption": "File Manager: Move",
"command": "fm_move"
Expand Down
1 change: 1 addition & 0 deletions FileManager.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"show_open_in_browser_command": true,
"show_open_terminal_command": true,
"show_rename_command": true,
"show_rename_path_command": true,
"show_create_from_selection_command": true,
"show_open_all_command": true,

Expand Down
2 changes: 1 addition & 1 deletion Side Bar.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"caption": "Rename...",
"mnemonic": "R",
"command": "fm_rename",
"command": "fm_rename_path",
"args": {
"paths": []
}
Expand Down
11 changes: 11 additions & 0 deletions commands/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@
from .appcommand import AppCommand


class FmRenamePathCommand(AppCommand):
def run(self, paths):
sublime.active_window().run_command("rename_path", {"paths": paths})


class FmRenameCommand(AppCommand):
def run(self, paths=None):
print(
"fm_rename has been deprecated. It doesn't provide any more useful feature "
"than the default command. You should use rename_path (for a "
"file or a folder) or rename_file (for a file) instead."
)
sublime.status_message("fm_rename has been deprecated (see console)")
self.settings = get_settings()
self.window = get_window()
self.view = self.window.active_view()
Expand Down
6 changes: 2 additions & 4 deletions prevent_default.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sublime_plugin
from Default.side_bar import RenamePathCommand


class NewFileAtCommand(sublime_plugin.WindowCommand):
Expand Down Expand Up @@ -33,13 +34,10 @@ def is_enabled(self):
return False


class RenamePathCommand(sublime_plugin.WindowCommand):
class RenamePathCommand(RenamePathCommand):
def is_visible(self):
return False

def is_enabled(self):
return False


class FindInFolderCommand(sublime_plugin.WindowCommand):
def is_visible(self):
Expand Down

0 comments on commit 492cf24

Please sign in to comment.