diff --git a/src/terminal/Screen.cpp b/src/terminal/Screen.cpp index 5f38a80579..56f62eaece 100644 --- a/src/terminal/Screen.cpp +++ b/src/terminal/Screen.cpp @@ -1643,7 +1643,7 @@ void Screen::renderImage(shared_ptr _image, cell.setImageFragment(rasterizedImage, CellLocation { offset.line, offset.column }); cell.setHyperlink(_state.cursor.hyperlink); }; - moveCursorTo(_topLeft.line + unbox(linesToBeRendered) - 1, _topLeft.column); + moveCursorTo(_topLeft.line + unbox(linesToBeRendered), _topLeft.column); } // If there're lines to be rendered missing (because it didn't fit onto the screen just yet) @@ -1667,7 +1667,7 @@ void Screen::renderImage(shared_ptr _image, } } // move ansi text cursor to position of the sixel cursor - moveCursorToColumn(_topLeft.column + _gridSize.columns.as()); + moveCursorToColumn(_topLeft.column); } template diff --git a/src/terminal/Screen_test.cpp b/src/terminal/Screen_test.cpp index 53862fd6db..db504e1fca 100644 --- a/src/terminal/Screen_test.cpp +++ b/src/terminal/Screen_test.cpp @@ -3372,8 +3372,8 @@ TEST_CASE("Sixel.simple", "[screen]") mock.writeToScreen(sixelData); - CHECK(mock.terminal.primaryScreen().cursor().position.column == ColumnOffset(8)); - CHECK(mock.terminal.primaryScreen().cursor().position.line == LineOffset(4)); + CHECK(mock.terminal.primaryScreen().cursor().position.column == ColumnOffset(0)); + CHECK(mock.terminal.primaryScreen().cursor().position.line == LineOffset(5)); for (auto line = LineOffset(0); line < boxed_cast(pageSize.lines); ++line) { @@ -3410,7 +3410,7 @@ TEST_CASE("Sixel.AutoScroll-1", "[screen]") mock.writeToScreen(sixelData); - CHECK(mock.terminal.primaryScreen().cursor().position.column == ColumnOffset(8)); + CHECK(mock.terminal.primaryScreen().cursor().position.column == ColumnOffset(0)); CHECK(mock.terminal.primaryScreen().cursor().position.line == LineOffset(3)); for (auto line = LineOffset(-1); line < boxed_cast(pageSize.lines); ++line) diff --git a/src/terminal/SixelParser.cpp b/src/terminal/SixelParser.cpp index 3d0f2d7b67..1806167313 100644 --- a/src/terminal/SixelParser.cpp +++ b/src/terminal/SixelParser.cpp @@ -440,8 +440,7 @@ void SixelImageBuilder::rewind() void SixelImageBuilder::newline() { sixelCursor_.column = {}; - - if (unbox(sixelCursor_.line) + 6 < unbox(maxSize_.height)) + if (unbox(sixelCursor_.line) + 6 < unbox(explicitSize_ ? size_.height : maxSize_.height)) sixelCursor_.line.value += 6; } @@ -477,6 +476,12 @@ void SixelImageBuilder::render(int8_t _sixel) void SixelImageBuilder::finalize() { + if (unbox(size_.height) == 1) + { + size_.height = Height::cast_from(sixelCursor_.line.value); + buffer_.resize(size_.area() * 4); + return; + } if (!explicitSize_) { Buffer tempBuffer(static_cast(size_.height.value * size_.width.value) * 4); diff --git a/src/terminal/SixelParser_test.cpp b/src/terminal/SixelParser_test.cpp index 69a4cfc6ed..029b08904b 100644 --- a/src/terminal/SixelParser_test.cpp +++ b/src/terminal/SixelParser_test.cpp @@ -338,3 +338,17 @@ TEST_CASE("SixelParser.newline", "[sixel]") } } } + +TEST_CASE("SixelParser.vertical_cursor_advance", "[sixel]") +{ + auto constexpr defaultColor = RGBAColor { 0, 0, 0, 255 }; + SixelImageBuilder ib( + { Width(5), Height { 30 } }, 1, 1, defaultColor, std::make_shared(16, 256)); + auto sp = SixelParser { ib }; + + sp.parseFragment("$-$-$-$-"); + sp.done(); + + REQUIRE(ib.size() == terminal::ImageSize { Width(1), Height(24) }); + REQUIRE(ib.sixelCursor() == CellLocation { LineOffset(24), ColumnOffset { 0 } }); +}