Repository navigation
fix: 「/ キーで中黒」の優先と、SigilWord の状態リセット漏れによる全角入力ロックの解消 - #857
Open
Mithril-3d wants to merge 6 commits into
Open
Mithril-3d wants to merge 6 commits into
Mithril-3d wants to merge 6 commits into
Conversation
…ret/mode change - Prioritize SlashAsMiddleDot over sigil pass-through when typing '/' at the beginning of composition or after kana/punctuation. - Reset SigilWord state and boundary tracking when characters are deleted via Backspace, caret moves, or mode switches. - Prevent Japanese input with leading '/' from being wrongly protected as a POSIX path in ProtectedSpan. - Add regression tests covering middle dot insertion, sigil pass-through recovery, and POSIX path protection.
Contributor
|
@Mithril-3d さん、Pull Request ありがとうございます! Meltype は GNU GPL v3 で公開していますが、GPL v3 の条件で使えない方には作者が個別に利用を認めることがあります。これを続けられるように、初めての方には次の貢献者ライセンス同意 (CLA) をお願いしています (詳しく)。
同意していただける場合は、この Pull Request に次の 1 行だけをコメントしてください (一度同意すれば、次の Pull Request からは不要です)。 英語なら ✅ @Mithril-3d さん、CLA への同意ありがとうございます。記録しました (コメント)。次の Pull Request からは不要です。 |
Author
|
CLA に同意します |
yksr-melt
reviewed
Oct 19, 2026
yksr-melt
left a comment
Owner
There was a problem hiding this comment.
レビューしました。SigilWord の状態がアプリ側で消された/キャレットが動いたときに戻らず全角入力がロックされる問題を、CaretMoved (passedVk=0 / クリック / フォーカス) と before の再確認で解除する方針は良いと思います。気になった点:
ProtectedSpan: 1 階層のパスが保護されなくなる
/の後ろが英字と-だけなら PosixPath にしない変更で/nihongoは日本語になりますが、/home・/tmp・/etc・/usrのような 1 階層の実在パスも保護対象から外れ、ローマ字としてかなになりそうです (/home→/ほめ)。辞書でローマ字として読める語だけ外す、または英単語判定 (IsDefinitelyEnglish) と組み合わせるなどの方が回帰が少ないと思います。テストも/homeなどのケースがあると安心です。SigilWord.PassesThroughのbefore.Length >= 20
記号が見つからなくてもbeforeが 20 文字以上なら名前の途中とみなす条件の意図 (before が切り詰められている場合?) がコメントから読み取れないので、理由を書くか定数に名前を付けてもらえると助かります。- Windows (
MeltypeEngine) とMeltypeSessionで条件が違う
MeltypeSession側はsettings.InputStyle != InputStyle.Kanaを見ていますが、MeltypeEngine.StartsComposition側の新しい条件にはありません。手前でかな入力を除外済みならコメントで、そうでなければ同じ条件に揃えた方が良さそうです。 CompositionControllerの_modeByKey = true;追加は他の変更との関係が diff だけでは分からないので、何を直すためか PR 説明かコメントに一言あると助かります。
Generated by Claude Code
Author
|
レビューいただきありがとうございます。 変更の内容
// POSIX / macOS の代表的なルートディレクトリ名。1 階層の /home や /tmp などは保護対象にする。
private static readonly HashSet<string> CommonRootDirectories = new(StringComparer.OrdinalIgnoreCase)
{
"bin", "boot", "dev", "etc", "home", "lib", "lib64", "media", "mnt", "opt",
"proc", "root", "run", "sbin", "srv", "sys", "tmp", "usr", "var",
"Users", "Applications", "Library", "System", "Volumes", "private", "Network", "cores", "data"
};
// 打ち始めの / を ・ にしたときでも、原文全体 (先頭から) が代表的なルートディレクトリや複数階層パス (/home, /tmp, /a/b など)
// として正当に保護される場合は、パスとして保護する。
var slash = _units is [{ Kana: "・", Raw: "/" }, ..];
var key = slash ? "・" + raw : raw;
if (_protectedCache is not null && _protectedCacheRaw == key) return _protectedCache;
if (slash)
{
var fullSpans = ProtectedSpanScanner.Scan(raw);
if (fullSpans.Count > 0 && fullSpans[0].Start == 0 && fullSpans[0].Kind is ProtectedKind.PosixPath or ProtectedKind.Url)
{
_protectedCache = fullSpans;
}
else
{
_protectedCache = ProtectedSpanScanner.Scan(raw[1..]).Select(s => s with { Start = s.Start + 1 }).ToList();
}
}
else
{
_protectedCache = ProtectedSpanScanner.Scan(raw);
}
_protectedCacheRaw = key;
return _protectedCache;
/// <summary>
/// ホスト (TSF やエディタ) が直前の文脈 (before) を渡す際、一定文字数 (例: 16〜32 文字) で切り詰めることがある。
/// 長い名前を入力中に先頭の記号 (/・$・@) が切り詰め境界より手前に押し出された場合でも、
/// 切り詰められたバッファ全体が名前文字で満たされていれば名前の途中とみなすための閾値。
/// </summary>
private const int TruncatedBeforeThreshold = 20;
// ... (PassesThrough 内の判定処理)
// 記号で始まっているか、あるいは before が切り詰められて記号が枠外に押し出された (バッファ全体が名前文字) かを判定する
if (!IsNameChar(before[^1]) || !(IsSigil(before[i]) || (i == 0 && before.Length >= TruncatedBeforeThreshold)))
if (!reconvert && settings.SigilWordsDirect && (_keyboardDirect || settings.InputStyle != InputStyle.Kana) &&
KeyText.CharFromKey(e.Vk, e.Scan, false) is { } typed &&
!(typed == '/' && !_keyboardDirect && settings.SlashAsMiddleDot && settings.InputStyle != InputStyle.Kana && !_sigil.IsActive) &&
_sigil.PassesThrough(typed, _line.Text))
if (VirtualKeys.IsHankakuZenkaku(vk))
{
SetMode(_text.IsAlphanumeric ? DisplayMode.Hiragana : DisplayMode.HalfWidthAlphanumeric);
// 半角/全角キーで変換ボックスの文字種を切り替えたあと、F6〜F10 と同様に次の打鍵で確定して新しい入力を始める。
_modeByKey = true;
return;
}確かめること「/ キーで中黒」が OFF の場合:
「/ キーで中黒」が ON の場合:
確認したこと
|
This branch has not been deployed
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.
変更の内容
Fixes #638
設定で「/ キーで中黒「・」」を有効にしている場合でも、行頭や日本語入力時に中黒が入力できない問題、およびその後に半角英数が素通しされ続けて全角日本語が打てなくなる不具合を修正しました。
/が、SlashAsMiddleDot設定よりも先に AI コマンド記号(Sigil)のパススルー判定に横取りされていたため、日本語入力時はSlashAsMiddleDotを優先して中黒(・)を変換ボックスに入れるよう修正しました。_sawBefore等)を適切にリセットし、以降のキー入力がコマンドの続きと誤認されて半角ロックが発生するのを防ぎました。ProtectedSpan.TryPosixPathにおいて、先頭のスラッシュのみで通常入力が POSIX パスとして誤保護されないよう判定を調整しました。SessionFacadeTests等に追加しました。確かめること
kyouhagoogledekensaku→ 今日はgoogleで検索wsldeshell→ wslでshell確認したこと
dotnet run --project src/Meltype.Core.Testsのテストが通る (Windows ならsrc/Meltype.Tests)貢献者ライセンス同意 (CLA)
bot のコメントに対し、すでに「CLA に同意します」とコメント済みです(同意確認済み)。