Skip to content

fix: expand tabs on paste to match tab-width setting - #17

Merged
suradet-ps merged 3 commits into
mainfrom
fix/tab-width-paste
Aug 3, 2026
Merged

fix: expand tabs on paste to match tab-width setting#17
suradet-ps merged 3 commits into
mainfrom
fix/tab-width-paste

Conversation

@suradet-ps

Copy link
Copy Markdown
Owner

Bug

When code with tab characters is pasted into the textarea, the raw tabs are left as-is, causing a visual mismatch between the textarea display and the canvas output.

Before: Pressing Tab inserts spaces (correct), but pasting code with \t characters leaves them as narrow single chars in textarea while canvas expands them.

After: Both Tab key and paste expand tabs to spaces based on the current tab-width setting.

Changes

  • Add on:paste handler to both code textareas (main + split-screen)
  • Expand tabs to spaces using current ab_width before inserting pasted text
  • Add ClipboardEvent and DataTransfer web-sys features

Test

  1. Set tab width to 4
  2. Copy code with tab characters from an external editor
  3. Paste into CodeFrame textarea
  4. Tabs should appear as 4 spaces in both textarea and canvas preview

Closes the tab-width paste bug found after Phase 6 merge.

When code with tab characters is pasted into the textarea, the raw tabs
now get expanded to spaces based on the current tab-width setting.

Previously, pressing Tab inserted spaces correctly, but pasting code with
actual tab characters left them as-is in the textarea, causing a visual
mismatch between the textarea display and the canvas output.

Changes:
- Add on:paste handler to both code textareas
- Expand tabs to spaces using current tab_width before inserting
- Add ClipboardEvent and DataTransfer web-sys features
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codeshot Ready Ready Preview Aug 3, 2026 3:41am

canvas_ref.get() inside spawn_local async block was outside reactive
tracking context, causing a Leptos warning. Changed to get_untracked()
since NodeRef access here doesn't need reactive tracking.
Tab width setting was causing bugs with pasted code and wasn't essential.
Hardcode tab_width=4 in ExportOptions. Tab key in textarea still inserts
4 spaces. Remove paste handlers and ClipboardEvent/DataTransfer features.
@suradet-ps
suradet-ps merged commit 6e523f1 into main Aug 3, 2026
12 checks passed
@suradet-ps
suradet-ps deleted the fix/tab-width-paste branch August 3, 2026 04:45
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.

1 participant