Repository navigation
perf: 検索の色付けを見えている範囲だけにし、前後の一致へ移れるようにする - #279
Open
mayo031042 wants to merge 2 commits into
Open
mayo031042 wants to merge 2 commits into
mayo031042 wants to merge 2 commits into
Conversation
折り返し表示では、文字の位置を求めるたびにその文字を含むトークンの先頭から測り直す。base64 のように区切りのない長い並びは 1 つのトークンになるため、検索の色付けやクリックのたびに 0.1 秒以上かかっていた。トークンを 8 文字ごとに分けて、この計算を短くする。サロゲートペアや結合文字など、1 つの文字として表示されるまとまりの途中では分けない。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
これまでは先頭から決まった数の一致だけを色付けしていたため、それより後ろの一致は見つけられなかった。一致の位置はすべて持っておき、色付けは画面に見えている範囲に限る。スクロールや大きさの変更に合わせて、見えなくなったものを外し、見えてきたものを付ける。隣り合う一致は 1 つの色付けにまとめる。 折り返した長い 1 行では、色付けの位置の計算に 1 回で数ミリ秒かかる。描くたびに計算し直すとスクロールが重くなるので、計算した位置を覚えておく。 次へ・前へのボタン(Enter / Shift+Enter と同じ)で前後の一致に移る。件数の横の欄に番号を入れると、その一致へ移る。対象のテキストが書き換わったときも検索し直す。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
#278 で RawTextPane を RSyntaxTextArea に置き換えた後の、検索まわりの改善です。
以前は先頭から決まった数の一致だけを色付けしていたため、それより後ろの一致は見つけられませんでした。
この PR では一致した位置をすべて保持し、色付けは画面に見えている範囲だけ行います。スクロールや大きさの変更に合わせて、見えなくなった色付けを外し、見えてきたものを付けます。あわせて、▼▲ のボタン(Enter / Shift+Enter と同じ)で前後の一致へ移れるようにし、件数の横の欄に番号を入れることで指定位置に飛べるようにしました。
もう一つは、折り返し表示での位置の計算の速さです。RSyntaxTextArea は文字の位置を求めるたびに、その文字を含むトークンの先頭から測り直します。base64 のように区切りのない長い並びは 1 つのトークンになるため、検索の色付けやクリックのたびに 0.1 秒以上かかっていました。トークンを 8 文字ごとに分けて、この計算を短くしています。サロゲートペアや結合文字など、1 文字として表示されるまとまりの途中では分けません。
なお、改行のない巨大な JSON を色付きで初めて描くときは、10 万字で 1 秒ほどかかることがあります。RSyntaxTextArea の位置の計算が行の先頭から測るためで、この PR ではここまでとしています。
SearchBox の一致の管理(SearchMatches)と PacketTokenMaker の分割にはテストを加え、
./gradlew spotlessCheckと./gradlew testが通ることを確認しています。🤖 Generated with Claude Code