Skip to content

fix: preserve full editor width by mirroring Vditor's centering padding#167

Merged
zaaack merged 1 commit into
zaaack:mainfrom
asalcedo29:ansalced/fix-vditor-full-width-padding
Jul 20, 2026
Merged

fix: preserve full editor width by mirroring Vditor's centering padding#167
zaaack merged 1 commit into
zaaack:mainfrom
asalcedo29:ansalced/fix-vditor-full-width-padding

Conversation

@asalcedo29

Copy link
Copy Markdown

Problem

On wide viewports, the editor content (and wide tables) only used about 2/3 of the available width, leaving a large unused gap on the right.

Root cause

Vditor's internal setPadding() computes symmetric centering padding as (containerWidth - options.preview.maxWidth) / 2 (maxWidth defaults to 800) and applies it as an inline style, e.g. padding: 10px 437.5px. This extension's main.css already overrode padding-left to a fixed 35px !important (to make room for the custom line-number gutter) but never overrode padding-right, leaving Vditor's large computed right-padding in place on wide viewports.

Fix

Added padding-right: 35px !important; to the .vditor-reset rule in media-src/src/main.css, mirroring the existing padding-left override, so the content area uses the full available width symmetrically.

Testing

  • Verified via a headless-browser (Playwright) probe against the built webview bundle: table/content width increased from ~1202px to ~1605px at a 1677px viewport (matching viewport - 35 - 35).
  • Verified visually via F5 Extension Development Host with a wide markdown table - content now fills the editor width instead of stopping at ~2/3.
  • npx tsc -p ./ --noEmit passes with no errors.

Vditor's setPadding() centers editable content by computing symmetric
left/right padding as (containerWidth - preview.maxWidth) / 2, applied
as an inline style. We already override padding-left to a fixed 35px
to leave room for our own gutter/toolbar, but without a matching
padding-right override, wide viewports kept vditor's large computed
right-padding, leaving a big unused gap on the right side of the
editor (most visible with wide tables/content).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d05628eb-b7db-49a9-a409-45afa11d4cce
@asalcedo29

Copy link
Copy Markdown
Author

@zaaack pls take a look at this PR :)

@zaaack
zaaack merged commit a0b7ed9 into zaaack:main Jul 20, 2026
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