Skip to content

Commit

Permalink
Feature: ANF: Setting to enable rename file will prefill
Browse files Browse the repository at this point in the history
  • Loading branch information
stoivo committed Dec 2, 2017
1 parent d5a6750 commit a5f062b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions AdvancedNewFile.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions advanced_new_file/anf_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -45,6 +46,7 @@
SETTINGS = [
ALIAS_SETTING,
DEFAULT_INITIAL_SETTING,
AUTOFILL_RENAME,
USE_CURSOR_TEXT_SETTING,
SHOW_FILES_SETTING,
SHOW_PATH_SETTING,
Expand Down
9 changes: 6 additions & 3 deletions advanced_new_file/commands/move_file_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a5f062b

Please sign in to comment.