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

Failed to save very large file 【保存超大文件失败】 #972

Open
lxgz12345 opened this issue Jan 27, 2025 · 3 comments
Open

Failed to save very large file 【保存超大文件失败】 #972

lxgz12345 opened this issue Jan 27, 2025 · 3 comments

Comments

@lxgz12345
Copy link

lxgz12345 commented Jan 27, 2025

【Chinese】
步骤:
1、打开366MB的test1.csv文件
2、打开“大文件模式”
3、选中其中的大部分行
4、按下Alt+D重复数据
5、再次按下Alt+D重复数据
6、另存为文件test2.csv
然后发现test2.csv为0KB。
另一个问题,打开991MB的文件会发生闪退。

【English from Google Translate】
Steps:

  1. Open the 366MB test1.csv file
  2. Open "Large File Mode"
  3. Select most of the lines
  4. Press Alt+D to repeat the data
  5. Press Alt+D again to repeat the data
  6. Save as test2.csv file
    Then find that test2.csv is 0KB.
    Another issue is that opening a 991MB file will cause a crash.

【구글 번역에서 한국어】
단계:

  1. 366MB test1.csv 파일을 엽니다.
  2. "대용량 파일 모드" 켜기
  3. 대부분의 행을 선택하세요
  4. Alt+D를 눌러 데이터를 반복합니다.
  5. Alt+D를 다시 눌러 데이터를 반복합니다.
  6. test2.csv 파일로 저장
    그러다가 test2.csv가 0KB인 것을 발견했습니다.
    또 다른 문제는 991MB 파일을 열면 충돌이 발생한다는 것입니다.

Image

@softmgr
Copy link

softmgr commented Feb 9, 2025

我测试了打开1GB的HTML文件不会闪退。再选择一些文本,按Alt+D重复几次,再按Ctrl+S保存没问题,保存后文件大小来到1.7GB。notepad4.exe 进程占用的内存来到4.4GB左右,没有崩溃。再次打开这个大文件,也能正常打开。看起来是csv语法高亮解析出的问题。

@zufuliu
Copy link
Owner

zufuliu commented Feb 9, 2025

I can't reproduce the bug (repeated Ctrl + D multiple times) use large CSV (222MB from issue #236) on a 16GB Win11.

Image

@zufuliu zufuliu added this to the v25.03 milestone Feb 10, 2025
zufuliu added a commit that referenced this issue Feb 10, 2025
… encoding

converting for file larger then 1GB to prevent failure, issue #972.
@zufuliu zufuliu added the 🛠workaround Workaround available label Feb 10, 2025
@zufuliu
Copy link
Owner

zufuliu commented Feb 10, 2025

Should be fixed by commit 6958ad0, please test latest build from https://github.com/zufuliu/notepad4/actions.

Inside EditSaveFile() function, convert text from UTF-8 to UTF-16 failed (cbDataWide is zero) when text (cbData) is longer than 1GB:

notepad4/src/Edit.cpp

Lines 1266 to 1267 in 6958ad0

LPWSTR lpDataWide = static_cast<LPWSTR>(NP2HeapAlloc(cbData * sizeof(WCHAR) + 16));
const int cbDataWide = MultiByteToWideChar(CP_UTF8, 0, lpData, cbData, lpDataWide, static_cast<int>(NP2HeapSize(lpDataWide) / sizeof(WCHAR)));

Current workaround: disable load ANSI as UTF-8 on File -> Encoding -> Default:
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants