Skip to content

Inconsistent & potentially misleading behaviour when calling List RemoveItem #632

@g026r

Description

@g026r

Describe the bug

RemoveItem, when called, operates both on the unfiltered list & the filtered list resulting in misleading & inconsistent behaviour.

If index < len(filteredItems) then filteredItems will be updated to remove the item at that index while simultaneously removing the item at the same index in the global list even if the two items do not match.

If index >= len(filteredItems) then the global list will be updated to remove the item at that index while the filtered list is simultaneously not updated, even if the item that was removed is currently visible in the filtered list.

Setup
Please complete the following information along with version numbers, if applicable.

  • OS [e.g. Ubuntu, macOS]: MacOS
  • Shell [e.g. zsh, fish]: fish
  • Terminal Emulator [e.g. kitty, iterm]: iTem
  • Terminal Multiplexer [e.g. tmux]: N/A
  • Locale [e.g. en_US.UTF-8, zh_CN.UTF-8, etc.]: en_US.UTF-8

To Reproduce
Steps to reproduce the behavior:

  1. Have a list.
  2. Filter such that the second item in the global list is the first item in the filtered list
  3. Call RemoveItem(0) on the filtered list
  4. Observe that the filtered list updates to show that the first item in it is removed
  5. Reset the filter
  6. The item removed from the filter is present, but item in position 0 is gone

Alternatively:

  1. Have a list.
  2. Filter such that the global index of the first item in the filtered list is beyond the length of the filter (e.g. filter is len(1) but item is in index 1 on the global list)
  3. Call RemoveItem(globalIndexOfFilteredItem) on the filtered list
  4. Observe that the filtered list does not update to show that the item has been removed
  5. Reset the filter
  6. Observe that the item which was still shown in the filter is no longer present in the global list

Source Code
Please include source code if needed to reproduce the behavior.

Expected behavior
When an item is shown as being removed from the filtered list, the same item should be removed from the global list. Likewise, when an item is removed from the global list, that item should be removed from the filtered list if it is present.

Screenshots
Add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions