Skip to content

Commit 416d26c

Browse files
authored
Merge pull request #171 from stoivo/master
Feature: ANF: rename file prefilles the input with the current file o…
2 parents b0b63b8 + a5f062b commit 416d26c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

AdvancedNewFile.sublime-settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// A default initial value to fill the create new file input path with.
1818
"default_initial": "",
1919

20+
// When renaming a file it will we pre populated with the file existing filename.
21+
"autofill_path_the_existing": false,
22+
2023
// A boolean defining if cursor text should be used. Text bound by single or
2124
// double quotes or within a region will be used. If multiple cursors
2225
// are used, the earliest selection containing a region or existing

advanced_new_file/anf_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
ALIAS_SETTING = "alias"
66
DEFAULT_INITIAL_SETTING = "default_initial"
7+
AUTOFILL_RENAME = "autofill_path_the_existing"
78
USE_CURSOR_TEXT_SETTING = "use_cursor_text"
89
SHOW_FILES_SETTING = "show_files"
910
SHOW_PATH_SETTING = "show_path"
@@ -45,6 +46,7 @@
4546
SETTINGS = [
4647
ALIAS_SETTING,
4748
DEFAULT_INITIAL_SETTING,
49+
AUTOFILL_RENAME,
4850
USE_CURSOR_TEXT_SETTING,
4951
SHOW_FILES_SETTING,
5052
SHOW_PATH_SETTING,

advanced_new_file/commands/move_file_command.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ def get_status_prefix(self):
123123
def get_default_root_setting(self):
124124
return RENAME_FILE_DEFAULT_ROOT_SETTING
125125

126+
def generate_initial_path(self):
127+
if self.settings.get("autofill_path_the_existing"):
128+
file_path = self.window.active_view().file_name()[1:]
129+
base, _ = self.split_path(file_path)
130+
return file_path[len(base):]
131+
else:
132+
return super(self.__class__, self).generate_initial_path()
133+
126134

127135
class AdvancedNewFileMoveAtCommand(sublime_plugin.WindowCommand):
128136
def run(self, files):

0 commit comments

Comments
 (0)