Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

特定文字の場合に SubString が例外を発生して プログラムが異常終了する。 #1

Closed
kkato233 opened this issue Sep 5, 2020 · 7 comments

Comments

@kkato233
Copy link
Owner

kkato233 commented Sep 5, 2020

PropWrapView.cs 744行目の SubString が例外を発生させる場合がある。

@kkato233
Copy link
Owner Author

kkato233 commented Sep 5, 2020

再現手順
 「View」「Wrap Lines」を ON
 文字列として タブを 2 つ入力
 画面の幅を狭くしていく。
 すると System.ArgumentOutOfRangeException が発生する。

この時

visCharCount = 1
token='\t'
peekingChar `{[1, 2)}`

image
image

@kkato233
Copy link
Owner Author

kkato233 commented Sep 5, 2020

ロジックの解説
行末が '\r\n' 、サロゲートペア , のような 文字として切り取ったらダメな文字がある場合に
その文字を 削らないように peekingChar に サロゲートの残りの文字数が設定される。

'\t' の場合に tokenEndPos に設定される X の値が 表示できる領域のサイズより小さいため
本来だと サロゲートペアや \r\n改行の文字は セットで切り取るため +peekingChar.Length
を足して 画面表示するというロジック。

DrawToken も 0文字だと例外を発生させるようなので この部分も修正が必要?

@kkato233
Copy link
Owner Author

kkato233 commented Sep 5, 2020

根本的には NextPaintToken が サロゲートペアを認識せずに Token 分割している場所だと思う。
だからむりやり サロゲートの描画のタイミングで 切り取りをしているのか??

@kkato233
Copy link
Owner Author

kkato233 commented Sep 5, 2020

画面の幅を短くして 画面の描画エリアよりも Windowの枠が小さい時に 文字列切り取りの処理をしている。
下記のような画面の場合
token = 𪚥𪚥𪚥𪚥𪚥𪚥𪚥𪚥 (サロゲート文字)
peekingChar = {[14, 15)}
peekingChar.Length = 1
本当は 最後の 𪚥 を切り取る のであれば サロゲートを意識して peekingChar.Length = 4 となるべきであるが・・
この計算が違うので 結果的に 四角が描画されている。(下記図2)

image
image

@kkato233 kkato233 changed the title 特定文字の場合に SubString が例外を発生させて プログラムが異常終了する。 特定文字の場合に SubString が例外を発生して プログラムが異常終了する。 Sep 5, 2020
@kkato233
Copy link
Owner Author

kkato233 commented Sep 5, 2020

いろんなバリエーションを検討してみたが、そもそも 画面に収まらないから 表示する文字を切り取るというのは
不要な処理では??
どうせ描画しても見えないだけなので・・。

@kkato233
Copy link
Owner Author

kkato233 commented Sep 5, 2020

かなり再現性の高いバグなので 開発元にも修正の依頼を出す。

@kkato233
Copy link
Owner Author

kkato233 commented Sep 6, 2020

8648259 の 修正結果 下記のように正常に動作するようになった。

image

テスト文字列 a𪚥𪚥𪚥𪚥𪚥𪚥𪚥𪚥𪚥𪚥𪚥aaaaaaaaa𪚥b𪚥c𪚥𪚥𪚥𪚥𪚥𪚥𪚥𪚥d𪚥e𪚥f𪚥

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

No branches or pull requests

1 participant