Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed `Content.expand_tabs` https://github.com/Textualize/textual/pull/6038
- Fixed return value for `Pilot.double_click` and `Pilot.triple_click` https://github.com/Textualize/textual/pull/6035
- Fixed sizing issue with `Pretty` widget https://github.com/Textualize/textual/pull/6040 https://github.com/Textualize/textual/pull/6041
- Fixed garbled inline app output when `inline_no_clear=True` https://github.com/Textualize/textual/pull/6080

### Added

Expand Down
7 changes: 3 additions & 4 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3294,8 +3294,9 @@ async def invoke_ready_callback() -> None:
if self._driver.is_inline:
cursor_x, cursor_y = self._previous_cursor_position
self._driver.write(
Control.move(-cursor_x, -cursor_y + 1).segment.text
Control.move(-cursor_x, -cursor_y).segment.text

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-cursor_y + 1 will duplicate the first line in the output. But I think this was included in case the app crashes so the traceback doesn't overwrite the prompt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another test app to check the prompt is correctly restored:

from textual.app import App, ComposeResult
from textual.widgets import Button

INLINE_NO_CLEAR = False

INVALID_CSS = False


class ExitRenderablesApp(App):
    CSS = "Screen { background: invalid; }" if INVALID_CSS else ""

    def compose(self) -> ComposeResult:
        yield Button.error("Runtime Error")

    def on_mount(self) -> None:
        # Show the terminal cursor for debugging
        self._driver.write("\x1b[?25h")

    def on_button_pressed(self) -> None:
        raise RuntimeError()


if __name__ == "__main__":
    app = ExitRenderablesApp()
    app.run(
        inline=True,
        inline_no_clear=INLINE_NO_CLEAR,
    )

)
self._driver.flush()
if inline_no_clear and not self.app._exit_renderables:
console = Console()
try:
Expand All @@ -3304,9 +3305,7 @@ async def invoke_ready_callback() -> None:
console.print()
else:
self._driver.write(
Control.move(
-cursor_x, -self.INLINE_PADDING - 1
).segment.text
Control.move(0, -self.INLINE_PADDING).segment.text
)

driver.stop_application_mode()
Expand Down
Loading