Skip to content

In Win10, Chrome/Firefox/Edge fails to unfold code correctly in jupyter's codemirror for this python code #5948

@pytkr

Description

@pytkr

If I click the triangle on the left of this class user_array line, the following will correctly fold to one line, however, when I unfold this line, only 11 lines are shown, the rest codes will not show unless I click the edit area.

In Win10 17134.855 x64, Chrome (75.0.3770.142) /Firefox (68.0.1) / Edge (42.17134.1.0) fails, however, IE 11.885.17134.0 successes to show without any extra click.

This is the code in jupyter notebook's input cell:

class user_array:
    def __init__(self, capacity: int):
        self._data = []
        self.capacity = capacity
        self._count = 0

    def __getitem__(self, index: int):
        if 0 <= index < self._count:
            return self._data[index]

    def find(self, index: int):
        return self._data[index]

    def update(self, index: int, value: int):
        if 0 <= index < self._count:
            self._data[index] = value
        else:
            raise AssertionError("index is out of range")

    def delete_element(self, index: int):
        if index > self._count or index < 0:
            raise AssertionError("index is out of range")
        if self._count == 0:
            raise AssertionError("array is empty")
        else:
            self._data = self._data[:index] + self._data[index + 1:-1]
            self._count = self._count - 1

    def insert_element(self, index: int, value: int):
        if index > self._count or index < 0:
            raise AssertionError("index is out of range")
        if index == 0:
            self._data = [value] + self._data
        elif index == self._count:
            self._data.append(value)
        elif 0 < index < self._count:
            self._data = self._data[:index] + [value] + self._data[index:]
        self._count = self._count + 1

    def insert_to_tail(self, element: int):
        if self._count < self.capacity:
            self._data.append(element)
            self._count = self._count + 1
        else:
            raise AssertionError("index is out of range")

    def return_array(self):
        return self._data

    def empty_arry(self):
        self._data = []
        self._count = 0
        self.capacity = 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions