Skip to content

fix(dncl): keep full-width characters inside strings and comments (#2621) - #2627

Merged
smalruby3-editor-bot[bot] merged 5 commits into
topic/japanese-mode-1731from
topic/autopilot-2621
Nov 29, 2026
Merged

smalruby3-editor-bot[bot] merged 5 commits into
topic/japanese-mode-1731from
topic/autopilot-2621

Conversation

@smalruby3-editor-bot

Copy link
Copy Markdown

Summary

日本語タブとルビータブの自動置換が、文字列の中の全角も半角にしていた(表示する("こんにちは!ABC") → "こんにちは!ABC")。自動置換は、文字列("…" '…'、日本語タブでは 「…」 も)とコメントの中を変えないようにした。docs/dncl/README.md の「文字列とコメントの中は書いたとおりに残す」と合う。

Changes Made

  • src/lib/auto-correct.js
    • 文字列の中は置換しない(以前は「文字列も置き換える」の設定 replaceInStrings が既定でオンだった)。
    • 全角の " ' とスマートクォート(“ ” ‘ ’)も文字列の囲みとして読む。同じ種類(ダブル / シングル)の引用符なら、半角でも全角でも文字列を閉じる。IME で puts("こんにちは!") と打っても ! が残り、囲みだけが " になる。
    • 使わなくなった isEscaped を消した。
  • 自動置換の設定から「文字列も置き換える」を外した(auto-correct-modal.jsx、ja.js / ja-Hira.js のキー。en.js にはこのキーが無かった)。localStorage に前の値が残っていても読まない。
  • docs: docs/ruby-editor/README.md の自動置換の説明と、docs/dncl/README.md の記述。

Test Coverage

  • test/unit/lib/auto-correct.test.js: 文字列を残す(" ' 「」、全角やスマートクォートの囲み、引用符の種類が混ざったとき、前に保存した設定)テストを足し、文字列の中を置換していた期待値を直した。
  • test/integration/auto-correct.test.js(中身は純粋関数のテスト): 期待値を直した。
  • ローカルでは上の 2 つと test/unit/containers/ruby-tab/auto-correct-apply.test.js を流し、bin/lint-changed を通した。

Closes #2621

🤖 Generated with Claude Code

The auto-correct no longer changes what is written in a string ("...", '...', and 「...」 in
the Japanese tab), in both the Japanese tab and the Ruby tab. Full-width and smart quotes
are read as the ends of a string, so an IME-typed "こんにちは!" keeps its !.
The "also replace inside strings" setting is removed; an old saved value is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@smalruby3-editor-bot smalruby3-editor-bot Bot added the 🤖 autopilot autopilot が処理対象にした Issue/PR(daemon が付与) label Nov 28, 2026
@smalruby3-editor-bot

smalruby3-editor-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Author

🤖 autopilot status

field value
Status Review
AI Status —
HITL No
Size middle

Linked issue #2621. Maintained by autopilot (single writer); do not edit.

@github-actions

Copy link
Copy Markdown

🚀 Preview deployed (stg API): https://preview.smalruby.app/topic-autopilot-2621-84f67de7/

The code in a #{} of a double-quoted Ruby string is code, so it is made half-width again
("#{x + 1}" -> "#{x + 1}"), as it was before strings were kept.
A string now ends at the end of its line in the Ruby tab too: while a quote is being typed
(an IME ” has no closing pair), the strings on the lines below were read as code and changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@smalruby3-editor-bot smalruby3-editor-bot Bot added the 🙋 HITL 人間の対応待ち(Project HITL=Yes の投影) label Nov 29, 2026
@smalruby3-editor-bot
smalruby3-editor-bot Bot marked this pull request as ready for review November 29, 2026 00:13
…ine end

A \ at the end of a line skipped the newline, so the string went on to the next line and
the text of the strings below was read as code and made half-width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@smalruby3-editor-bot

Copy link
Copy Markdown
Author

🤖 敵対的レビュー(round 1): 指摘 6 件(Must 2 / Question 1 / FYI 3)

Must

  • [M1] packages/scratch-gui/src/lib/auto-correct.js:194 文字列の中を置き換えなくなったため、"…" の中の #{…}(式展開)の式も全角のまま残る。puts("#{x + 1}") は前は #{x + 1} に直っていたが、直らなくなり実行できない(退行) — 修正済み(2a348aeb09)。"…" の #{ から対応する } までを式として読み、半角にする。'…'・\#{・日本語タブは対象外。テストを追加
  • [M2] packages/scratch-gui/src/lib/auto-correct.js:224 ルビータブでは文字列が行をまたいで続くので、打っている途中の閉じていない引用符(IME の ” は Monaco が自動で閉じない)で、下の行の文字列の中身がコードとして読まれ、黙って半角に変わる(y = ” の下の puts("ABC") が "ABC" になる)。プログラム全体を毎回置き換えるので、閉じたあとも元に戻らない — 修正済み(2a348aeb09)。日本語タブと同じく、文字列と #{…} をその行の終わりまでと読む(複数行の文字列の 2 行目からは置き換わるが、前の既定と同じ)。テストと docs/ruby-editor/README.md を更新

Question

  • [Q1] packages/scratch-gui/src/lib/auto-correct.js:207 文字列の中の \ が行の終わりにあると、改行を飛ばして文字列が次の行へ続く。閉じていない文字列(IME の ” など)の行が \ で終わると、下の行の文字列の中身がコードとして読まれ、黙って半角に変わる(puts("a\ の下の puts("ABC") が "ABC" になる)。docs の「文字列はその行の終わりまで」と食い違う。まれな打ち方 — 修正済み(f3a112feea)。行の終わりの \ は改行を飛ばさない。テストを追加

FYI

  • [FYI1] packages/scratch-gui/src/lib/auto-correct.js:149 #{…} の中の入れ子の文字列("#{"a"}")は式として置き換わり、その中の } で式が閉じたと読む。#@x / #$x の式展開は文字列として残る — 見送り: 情報共有のみ(生徒のプログラムではまれで、正しく読むには字句解析を深くする必要がある)
  • [FYI2] packages/scratch-gui/src/lib/auto-correct.js:122 同じ種類の引用符なら半角でも全角でも文字列を閉じるので、"彼は“はい”と言った" のように半角の文字列の中に “ ” を書くと、そこで文字列が切れて囲みが半角になる — 見送り: 振る舞いが変わる(IME で開けて半角で閉じる打ち方を受け付けるための決まり。前の既定でも中の “ は半角になっていた)
  • [FYI3] packages/scratch-gui/src/containers/ruby-tab.jsx:156 localStorage(smalruby:autoCorrectSettings)に前の replaceInStrings が残り、設定を変えると書き戻されるが、autoCorrect も設定画面も読まないので害はない(テスト済み) — 見送り: 情報共有のみ

直してほしい指摘は、モニターの「AI に直してもらう」で指示を書くか、Request changes で ID を指定してから 🙋 HITL を外してください(例: Q1はOK, FYI1は修正して)。ふつうのコメントだけでは autopilot は動きません。

@smalruby3-editor-bot smalruby3-editor-bot Bot removed the 🙋 HITL 人間の対応待ち(Project HITL=Yes の投影) label Nov 29, 2026
@smalruby3-editor-bot
smalruby3-editor-bot Bot merged commit d94b371 into topic/japanese-mode-1731 Nov 29, 2026
11 checks passed
@smalruby3-editor-bot
smalruby3-editor-bot Bot deleted the topic/autopilot-2621 branch November 29, 2026 00:43

This branch was previously deployed

1 inactive deployment
stg — f3a112fe Deployed Nov 29, 2026 by smalruby3-editor-bot[bot] via cleanup #665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 autopilot autopilot が処理対象にした Issue/PR(daemon が付与)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants