From 4ba7dd2c5e6f087a9dbd1ed7a083705b6b8dbc7d Mon Sep 17 00:00:00 2001 From: Arthur Sonzogni Date: Sat, 29 Mar 2025 12:51:08 +0100 Subject: [PATCH] Window: Major crash fix. (#1021) A patch handling focus was recently merged, but a special condition on Windows was inverted, causing a segfault. Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1020 --- .github/workflows/build.yaml | 2 +- CHANGELOG.md | 7 +++++++ src/ftxui/dom/focus.cpp | 2 +- src/ftxui/dom/node.cpp | 38 ++++++++++++++++++------------------ 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2eafd16b..f9149b74 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -104,7 +104,7 @@ jobs: --gcov-executable '${{ matrix.gcov_executable }}'; - name: Windows - Test and coverage - if: runner.os == 'Windows' && false + if: runner.os == 'Windows' working-directory: ./build run: > OpenCppCoverage.exe diff --git a/CHANGELOG.md b/CHANGELOG.md index f59e13ab..3c754261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +Unreleased +----- + +### Component +- BugFix: Fix major crash on Windows affecting all components. See #1020 +- BugFix: Fix focusRelative. + 6.0.1 (2025-03-28) ----- diff --git a/src/ftxui/dom/focus.cpp b/src/ftxui/dom/focus.cpp index 887cd933..647d4b32 100644 --- a/src/ftxui/dom/focus.cpp +++ b/src/ftxui/dom/focus.cpp @@ -36,7 +36,7 @@ Decorator focusPositionRelative(float x, float y) { void ComputeRequirement() override { NodeDecorator::ComputeRequirement(); - requirement_.focused.enabled = false; + requirement_.focused.enabled = true; requirement_.focused.node = this; requirement_.focused.box.x_min = int(float(requirement_.min_x) * x_); requirement_.focused.box.y_min = int(float(requirement_.min_y) * y_); diff --git a/src/ftxui/dom/node.cpp b/src/ftxui/dom/node.cpp index 10401a3a..f17631bb 100644 --- a/src/ftxui/dom/node.cpp +++ b/src/ftxui/dom/node.cpp @@ -125,27 +125,27 @@ void Render(Screen& screen, Node* node, Selection& selection) { node->Select(selection); } - // Setting the cursor to the right position allow folks using CJK (China, - // Japanese, Korean, ...) characters to see their [input method editor] - // displayed at the right location. See [issue]. - // - // [input method editor]: - // https://en.wikipedia.org/wiki/Input_method - // - // [issue]: - // https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-505282355 - // - // Unfortunately, Microsoft terminal do not handle properly hiding the - // cursor. Instead the character under the cursor is hidden, which is a big - // problem. As a result, we can't enable setting cursor to the right - // location. It will be displayed at the bottom right corner. - // See: - // https://github.com/microsoft/terminal/issues/1203 - // https://github.com/microsoft/terminal/issues/3093 if (node->requirement().focused.enabled #if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK) - || - node->requirement().focused.cursor_shape == Screen::Cursor::Shape::Hidden + // Setting the cursor to the right position allow folks using CJK (China, + // Japanese, Korean, ...) characters to see their [input method editor] + // displayed at the right location. See [issue]. + // + // [input method editor]: + // https://en.wikipedia.org/wiki/Input_method + // + // [issue]: + // https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-505282355 + // + // Unfortunately, Microsoft terminal do not handle properly hiding the + // cursor. Instead the character under the cursor is hidden, which is a + // big problem. As a result, we can't enable setting cursor to the right + // location. It will be displayed at the bottom right corner. + // See: + // https://github.com/microsoft/terminal/issues/1203 + // https://github.com/microsoft/terminal/issues/3093 + && + !node->requirement().focused.cursor_shape == Screen::Cursor::Shape::Hidden #endif ) { screen.SetCursor(Screen::Cursor{