Skip to content

Prevent editor clipping in narrow windows - #18

Open
theMTset wants to merge 2 commits into
omacom-io:masterfrom
theMTset:fix/narrow-window-editor-clipping
Open

Prevent editor clipping in narrow windows#18
theMTset wants to merge 2 commits into
omacom-io:masterfrom
theMTset:fix/narrow-window-editor-clipping

Conversation

@theMTset

@theMTset theMTset commented Aug 19, 2026

Copy link
Copy Markdown

Summary

Allow the editor to shrink to the space available inside its existing 24 px side margins.

Hyprland can resize Omawrite below its declared minimum window width. Below 408 px, the previous 360 px editor floor exceeded the viewport and clipped text on both sides.

This preserves the existing margins and 65-character maximum width at normal window sizes. It only changes behavior when the window is too narrow for the previous minimum.

Validation

  • Manually tested in a 394 px-wide tiled window
  • Confirmed the text remains visible and wraps without clipping
  • Confirmed normal margins and wide-window layout are unchanged
  • ./bin/test — 12 passed
  • ./bin/build
  • git diff --check

@theMTset

Copy link
Copy Markdown
Author

Closing so the change can be tested and reviewed locally before any future submission.

@theMTset theMTset closed this Aug 19, 2026
@theMTset theMTset reopened this Aug 19, 2026
@theMTset theMTset changed the title Fix editor clipping in narrow windows Prevent editor clipping in narrow windows Aug 19, 2026
Removing the 360px floor is the right fix — below a 408px window it exceeded the Flickable's viewport and the outer Math.min could no longer bring the column down, so the first and last characters of every line were clipped away — but replacing the proportional margin with a flat 48px changes the layout far outside that range. 48px is exactly the Flickable's own two 24px insets, so the column now grows to the full viewport at every window width below 1020: at the 720px minimum the window itself asks for, the text sits 24px from each edge instead of 120px, and at twice the desktop text size it sits 24px from each edge instead of 240px.

Restore the twenty-character margin as a third argument to the same Math.min, alongside the viewport clamp. The column is then identical to before at every width where it already fitted, and shrinks with the window below 408px where it did not.

The test drives the window to 394px, the width the clipping was reported at, and asserts the column stays inside the viewport there and still keeps a margin of its own at the declared minimum width. It fails both ways without this: with the 360px floor the column is 360px inside a 346px viewport, and with the flat margin it fills the viewport edge to edge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

The floor removal is the right diagnosis. Below a 408px window the 360px floor exceeded the Flickable's viewport (width - 48, from its two 24px insets) and the outer Math.min could no longer bring the column down, so editor.x went negative and the clip took the first and last characters of every line. Instrumented against src/Main.qml at 394px: a 360px column inside a 346px viewport, x = -7.

The flat 48px is the part that needs another look. It is exactly those two insets, so wherever it binds the column fills the viewport edge to edge — and the result differs from master at every window width below 1020px, not only below 408px. At the 720px minimum the window itself declares, the column goes from 480px to 672px and the margin from 120px to 24px per side. At twice the desktop text size the margin was 240px per side and becomes 24px, and the two expressions only agree again at 2040px. So "preserves the existing margins ... at normal window sizes" does not hold: the change is invisible only at the default 1280px window, where the 65-character cap already binds and master is capped too.

I pushed cb3a5a3, which keeps your clamp and puts the proportional margin back as a third argument to the same Math.min. That is min(master, max(0, width - 48)): identical to master at every width where the column already fitted, and identical to yours below 408px where it did not.

It also adds keepsTextColumnInsideNarrowWindows to tests/tst_omawrite.cpp, which drives the window to 394px — the width you reported — and asserts the column stays inside the viewport there and still keeps a margin of its own at the declared minimum width. It fails both ways without the fix: 360px inside a 346px viewport with the old floor, and x == 0 with the flat margin.

Worth knowing before this lands: it conflicts textually with #5, which rewrites the same editorWidth block for its heading gutter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants