From 11b3618242a85a5d0805befa8c3fdddf764e4105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Wed, 26 Jun 2024 12:14:28 +0200 Subject: [PATCH] rename file_name to path and improve initial_selection --- plugin/rename_file.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugin/rename_file.py b/plugin/rename_file.py index fe2e59ac6..b109bf6a3 100644 --- a/plugin/rename_file.py +++ b/plugin/rename_file.py @@ -13,26 +13,24 @@ class RenameFileInputHandler(sublime_plugin.TextInputHandler): def want_event(self) -> bool: return False - def __init__(self, path: str) -> None: - self.path = path + def __init__(self, file_name: str) -> None: + self.file_name = file_name def name(self) -> str: return "new_name" def placeholder(self) -> str: - return self.path + return self.file_name def initial_text(self) -> str: return self.placeholder() def initial_selection(self) -> list[tuple[int, int]]: - end_point = self.path.rfind('.') - if end_point == -1: - end_point = len(self.path) + end_point = self.file_name.rfind('.') return [(0, end_point)] - def validate(self, path: str) -> bool: - return len(path) > 0 + def validate(self, name: str) -> bool: + return len(name) > 0 class LspRenameFileCommand(LspWindowCommand):