Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting multiple selected files from right to left, results in IndexError #97

Closed
GiorgosXou opened this issue Apr 8, 2024 · 1 comment
Labels
bug Something isn't working Solved

Comments

@GiorgosXou
Copy link
Owner

tuifi_issue_delete_right_to_left_Peek 2024-04-08 22-26

Issue:

else: # if self.__count_selected > 1: # Why do i even > 1 very sus
if self.__clicked_file:
temp_i = self.__index_of_clicked_file - self.__count_selected
else:
temp_i = 0 # VERY SUS BUT NVM NOW
for f in self.files:
if f.is_selected:
self.__delete_file(f)
if self.__count_selected == 0:
self.reload(keep_search_results=True)
self.__index_of_clicked_file = temp_i
self.__clicked_file = self.files[temp_i]
self.__pre_clicked_file = None # hmm.. sus
self.select(self.__clicked_file)
break

Fixed solution:

else: # if self.__count_selected > 1:  # Why do i even > 1 very sus
    temp_i=0
    for f in self.files:
        if f.is_selected: # first file is never selected because it is the .. one
            temp_i-=1
            self.__delete_file(f)
            if self.__count_selected == 0:
                break
        temp_i+=1
    self.reload(keep_search_results=True)
    self.__index_of_clicked_file = temp_i
    self.__clicked_file          = self.files[temp_i]
    self.__pre_clicked_file      = None # hmm.. sus
    self.select(self.__clicked_file)
@GiorgosXou GiorgosXou added bug Something isn't working Solved labels Apr 8, 2024
@GiorgosXou
Copy link
Owner Author

Improved and fixed

    def delete(self):
        """
        Deletes the selected file(s). | Not fully implemented yet
        """
        if not self.has_write_access(self.directory): return
        if self.__count_selected == 1 and self.__clicked_file :
            # checking under __delete_file too but nvm cause i have no time right now
            if self.__clicked_file.name != '..':
                self.__delete_file(self.__clicked_file)
                self.files.pop(self.__index_of_clicked_file)
                temp_i = self.__index_of_clicked_file - 1
                self.resort() # replaced -> self.reload(keep_search_results=True)
                self.__index_of_clicked_file = temp_i
                self.__clicked_file          = self.files[temp_i]
                self.__pre_clicked_file      = None # hmm.. sus?
                self.__pre_hov               = None           
                self.select(self.__clicked_file)
        else: # if self.__count_selected > 1:  # Why do i even > 1 very sus
            temp_i=0
            while True:
                if self.files[temp_i].is_selected: # first file is never selected because it is the .. one
                    self.__delete_file(self.files[temp_i])
                    del self.files[temp_i]
                    temp_i-=1
                    if self.__count_selected == 0:
                        break
                temp_i+=1
            self.resort() # replaced -> self.reload(keep_search_results=True)
            self.__index_of_clicked_file = temp_i
            self.__clicked_file          = self.files[temp_i]
            self.__pre_clicked_file      = None # hmm.. sus
            self.__pre_hov               = None           
            self.select(self.__clicked_file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Solved
Projects
None yet
Development

No branches or pull requests

1 participant