From 6f654623cbedfd7f4dada7269783861d68c5b344 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:13:56 +0200 Subject: [PATCH] improve initial_selection and rename file_name to path --- plugin/rename_file.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugin/rename_file.py b/plugin/rename_file.py index b109bf6a3..fe2e59ac6 100644 --- a/plugin/rename_file.py +++ b/plugin/rename_file.py @@ -13,24 +13,26 @@ class RenameFileInputHandler(sublime_plugin.TextInputHandler): def want_event(self) -> bool: return False - def __init__(self, file_name: str) -> None: - self.file_name = file_name + def __init__(self, path: str) -> None: + self.path = path def name(self) -> str: return "new_name" def placeholder(self) -> str: - return self.file_name + return self.path def initial_text(self) -> str: return self.placeholder() def initial_selection(self) -> list[tuple[int, int]]: - end_point = self.file_name.rfind('.') + end_point = self.path.rfind('.') + if end_point == -1: + end_point = len(self.path) return [(0, end_point)] - def validate(self, name: str) -> bool: - return len(name) > 0 + def validate(self, path: str) -> bool: + return len(path) > 0 class LspRenameFileCommand(LspWindowCommand):