Skip to content

Commit

Permalink
avoid multiple statements on one line
Browse files Browse the repository at this point in the history
  • Loading branch information
predragnikolic committed Jun 27, 2024
1 parent 437659f commit 3647f92
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions plugin/rename_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def run(
view = self.window.active_view()
old_path = self.get_old_path(dirs, files, view)
if old_path is None: # handle renaming buffers
if view: view.set_name(new_name)
if view:
view.set_name(new_name)
return
new_path = os.path.normpath(Path(old_path).parent / new_name)
if os.path.exists(new_path):
Expand All @@ -87,9 +88,12 @@ def run(
)

def get_old_path(self, dirs: list[str] | None, files: list[str] | None, view: sublime.View | None) -> str | None:
if dirs: return dirs[0]
if files: return files[0]
if view: return view.file_name()
if dirs:
return dirs[0]
if files:
return files[0]
if view:
return view.file_name()

def handle(self, res: WorkspaceEdit | None, session_name: str,
old_path: str, new_path: str, rename_file_params: RenameFilesParams) -> None:
Expand Down

0 comments on commit 3647f92

Please sign in to comment.