diff --git a/cheuph/attributed_lines.py b/cheuph/attributed_lines.py index 1285141..acd8e94 100644 --- a/cheuph/attributed_lines.py +++ b/cheuph/attributed_lines.py @@ -75,7 +75,7 @@ class AttributedLines: AttributedLines's offsets instead. """ - self._lines.extendleft(lines._lines) + self._lines.extendleft(reversed(lines._lines)) self.upper_offset -= len(lines) def extend_below(self, lines: "AttributedLines") -> None: @@ -105,6 +105,7 @@ class AttributedLines: attr_lines = AttributedLines(lines) attr_lines.upper_offset = max(start_offset, self.upper_offset) + attr_lines.lower_offset = min(end_offset, self.lower_offset) return attr_lines def to_size(self, start_offset: int, end_offset: int) -> "AttributedLines": diff --git a/cheuph/cursor_rendering.py b/cheuph/cursor_rendering.py index 48c26e3..57c3455 100644 --- a/cheuph/cursor_rendering.py +++ b/cheuph/cursor_rendering.py @@ -156,8 +156,10 @@ class CursorTreeRenderer(Generic[E]): ) -> AttributedLines: lines = AttributedLines() width = self._width - len(indent) - self._renderer.meta_width + meta_spaces = AT(" " * self._renderer.meta_width) attrs = {"cursor": True, "offset": 0} - lines.append_below(attrs, self._renderer.render_cursor(width)) + lines.append_below(attrs, meta_spaces + indent + + self._renderer.render_cursor(width)) return lines def _render_indent(self, @@ -217,7 +219,7 @@ class CursorTreeRenderer(Generic[E]): lines.lower_offset = -1 cursor_indent = indent + self._render_indent(cursor_line=True) - lines.extend_below(self._render_cursor(indent)) + lines.extend_below(self._render_cursor(cursor_indent)) def _render_tree(self, root_id: Id) -> AttributedLines: lines = AttributedLines() @@ -350,8 +352,9 @@ class CursorTreeRenderer(Generic[E]): if self._cursor_id is None and self._anchor_id is None: return self._render_lines_from_cursor() + working_id: Id if self._anchor_id is None: - working_id = self._cursor_id + working_id = self._cursor_id # type: ignore else: working_id = self._anchor_id diff --git a/cheuph/element_supply.py b/cheuph/element_supply.py index c427225..da20fa6 100644 --- a/cheuph/element_supply.py +++ b/cheuph/element_supply.py @@ -174,7 +174,7 @@ class InMemorySupply(ElementSupply[E]): return elem.parent_id def _roots(self) -> List[Id]: - roots = (m for m in self._elements.values() if m.parent_id is None) + roots = (i for i, m in self._elements.items() if m.parent_id is None) return list(sorted(roots)) def sibling_ids(self, elem_id: Id) -> List[Id]: @@ -189,6 +189,6 @@ class InMemorySupply(ElementSupply[E]): roots = self._roots() if roots: - return roots[:-1] + return roots[-1] else: return None