fix: crop right whitespace from Ruby tab screenshot#324
Merged
takaokouji merged 3 commits intodevelopfrom Mar 16, 2026
Merged
Conversation
Scan pixel data after capture to find the rightmost non-white column, then trim the image to that boundary plus a small padding. This removes the large right-side whitespace that appeared when editor width exceeded code length. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/fix/screenshot-crop-right-whitespace/ |
The cursor line highlight and scrollbar span the full editor width, which prevents cropRightWhitespace from detecting the true content boundary. Temporarily set renderLineHighlight to 'none' and hide scrollbars during capture. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pixel scanning could not reliably detect the content boundary due to Monaco's decorative elements (overview ruler, scrollbar, line highlight) spanning the full editor width. Instead, measure the actual rendered text and furigana span widths from the DOM before capture, then crop the image to that width using Canvas API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions bot
pushed a commit
that referenced
this pull request
Mar 16, 2026
…t-crop-right-whitespace fix: crop right whitespace from Ruby tab screenshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes Made
cropRightWhitespace()関数を追加(ruby-screenshot.js)createImageBitmap→ CanvasgetImageDataで右端から列スキャンdownloadRubyAsImage()からcropRightWhitespace()を呼び出しTest Coverage
cropRightWhitespace: クロップ動作、余白少ない場合のスキップ、アンチエイリアス検出、全面コンテンツ、デフォルトパディングdownloadRubyAsImageのbeforeEachに Canvas/ImageBitmap モック追加)Definition of Done