Skip to content

Commit

Permalink
remomve few lines
Browse files Browse the repository at this point in the history
  • Loading branch information
predragnikolic committed Jul 2, 2024
1 parent 3389f66 commit 4785d49
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions plugin/rename_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ def run(
self.rename_path(old_path, new_path)
self.notify_did_rename(rename_file_params, new_path, view)
return
capability = session.get_capability('workspace.fileOperations.willRename')
if not capability:
return
filters = FileOperationFilterMatcher(capability.get('filters'))
if filters.matches(old_path, view):
filters = (session.get_capability('workspace.fileOperations.willRename') or {}).get('filters')
if filters and FileOperationFilterMatcher(filters).matches(old_path, view):
request = Request.willRenameFiles(rename_file_params)
session.send_request(
request,
lambda res: self.handle(res, session.config.name, old_path, new_path, rename_file_params, view)
)
else:
self.rename_path(old_path, new_path)
self.notify_did_rename(rename_file_params, new_path, view)

def get_old_path(self, dirs: list[str] | None, files: list[str] | None, view: sublime.View | None) -> str | None:
if dirs:
Expand Down Expand Up @@ -138,10 +138,9 @@ def restore_regions(v: sublime.View | None) -> None:

def notify_did_rename(self, rename_file_params: RenameFilesParams, path: str, view: sublime.View | None):
for s in self.sessions():
capability = s.get_capability('workspace.fileOperations.didRename')
if not capability:
filters = (s.get_capability('workspace.fileOperations.didRename') or {}).get('filters')
if not filters:
continue
filters = FileOperationFilterMatcher(capability.get('filters'))
if filters.matches(path, view):
if FileOperationFilterMatcher(filters).matches(path, view):
s.send_notification(Notification.didRenameFiles(rename_file_params))

0 comments on commit 4785d49

Please sign in to comment.