Skip to content

Grepで検索したファイルの合計(KB)が上限を超えるなら足さない - #2846

Merged
berryzplus merged 2 commits into
sakura-editor:masterfrom
hpmy-dev:fix/grep-searched-size-overflow
Nov 11, 2026
Merged

berryzplus merged 2 commits into
sakura-editor:masterfrom
hpmy-dev:fix/grep-searched-size-overflow

Conversation

@hpmy-dev

Copy link
Copy Markdown
Contributor

リアルタイム表示で早めに出力するために数えている「前回の出力から検索したファイルの合計(KB)」が、
2TB を超えるファイルや合計で負になったり、あふれたりする不具合を直します。

変更内容

  • grep::AddFileSizeKB() を足しました。ファイルの大きさを 64 ビットのまま KB にし(端数は切り上げ)、合計に足すと上限(10000KB、約 10MB)を超えるなら足さずに、超えることを返します

  • 戻り値は grep::SAddFileSizeResult(足した後の合計と、上限を超えるか)です。
    explicit operator bool() で if( result ) と書けます(apiwrap::SGetTextResult に倣いました)

  • AppendResultIfDue() は、上限を超えるならすぐ出力するようにし、10000 < nWork の比べは AddFileSizeKB() の中に移しました

合計は上限を超えないので int のままあふれません。
10MB 以下のときと、10MB を超えたときに出力する時機は今と同じです。

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Test Results

1 941 tests  +1   1 941 ✅ +1   10m 20s ⏱️ + 2m 20s
  174 suites +1       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit ab9c6bd. ± Comparison against base commit 61da12b.

♻️ This comment has been updated with latest results.

berryzplus
berryzplus previously approved these changes Nov 11, 2026

@berryzplus berryzplus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対応ありがとうございます。

Comment thread sakura_core/agent/CGrepAgent.h Resolved
}
if( out.pOutput->IsDrawing() && 10000 < nWork ){
nHitCountOld = -100; // 即表示
if( !grep::AddFileSizeKB( nWork, nFileSize ) ){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

書いてから気付いたんですけどね。

「if文くっつけて」のSonarQube指摘が出ると思います。

	if( out.pOutput->IsDrawing() &&
		L'\0' != pszKey[0] &&
		!grep::AddFileSizeKB( nWork, nFileSize ) ){

保守性に関する指摘は、スルーで構わない認識です。
(できれば対応したいですが、あんまり重要ではない。)

@sonarqubecloud

Copy link
Copy Markdown

@berryzplus
berryzplus merged commit 1b885d6 into sakura-editor:master Nov 11, 2026
17 checks passed
@hpmy-dev
hpmy-dev deleted the fix/grep-searched-size-overflow branch November 16, 2026 08:23
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.

2 participants