From a5f062b34c2c63d0b2c95c3fc8a2f7834da7a945 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 2 Dec 2017 14:33:36 +0100 Subject: [PATCH] Feature: ANF: Setting to enable rename file will prefill --- AdvancedNewFile.sublime-settings | 3 +++ advanced_new_file/anf_util.py | 2 ++ advanced_new_file/commands/move_file_command.py | 9 ++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/AdvancedNewFile.sublime-settings b/AdvancedNewFile.sublime-settings index 2a74b62..b4fcb94 100644 --- a/AdvancedNewFile.sublime-settings +++ b/AdvancedNewFile.sublime-settings @@ -17,6 +17,9 @@ // A default initial value to fill the create new file input path with. "default_initial": "", + // When renaming a file it will we pre populated with the file existing filename. + "autofill_path_the_existing": false, + // A boolean defining if cursor text should be used. Text bound by single or // double quotes or within a region will be used. If multiple cursors // are used, the earliest selection containing a region or existing diff --git a/advanced_new_file/anf_util.py b/advanced_new_file/anf_util.py index 4bc7b99..cfb837b 100644 --- a/advanced_new_file/anf_util.py +++ b/advanced_new_file/anf_util.py @@ -4,6 +4,7 @@ ALIAS_SETTING = "alias" DEFAULT_INITIAL_SETTING = "default_initial" +AUTOFILL_RENAME = "autofill_path_the_existing" USE_CURSOR_TEXT_SETTING = "use_cursor_text" SHOW_FILES_SETTING = "show_files" SHOW_PATH_SETTING = "show_path" @@ -45,6 +46,7 @@ SETTINGS = [ ALIAS_SETTING, DEFAULT_INITIAL_SETTING, + AUTOFILL_RENAME, USE_CURSOR_TEXT_SETTING, SHOW_FILES_SETTING, SHOW_PATH_SETTING, diff --git a/advanced_new_file/commands/move_file_command.py b/advanced_new_file/commands/move_file_command.py index f2581aa..11fcdb7 100644 --- a/advanced_new_file/commands/move_file_command.py +++ b/advanced_new_file/commands/move_file_command.py @@ -124,9 +124,12 @@ def get_default_root_setting(self): return RENAME_FILE_DEFAULT_ROOT_SETTING def generate_initial_path(self): - file_path = self.window.active_view().file_name()[1:] - base, _ = self.split_path(file_path) - return file_path[len(base):] + if self.settings.get("autofill_path_the_existing"): + file_path = self.window.active_view().file_name()[1:] + base, _ = self.split_path(file_path) + return file_path[len(base):] + else: + return super(self.__class__, self).generate_initial_path() class AdvancedNewFileMoveAtCommand(sublime_plugin.WindowCommand):