mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
Merge pull request #4788 from RaiKoHoff/Dev_Master
Option: do not save blank new files
This commit is contained in:
commit
3dca6473ae
@ -31,6 +31,7 @@ SettingsVersion=5
|
||||
;FindReplaceOpacityLevel=50
|
||||
;RelativeFileMRU=1
|
||||
;ReuseWindow=0
|
||||
;SaveBlankNewFile=true
|
||||
;SciFontQuality=3
|
||||
;SimpleIndentGuides=0
|
||||
;SingleFileInstance=1
|
||||
|
||||
@ -89,6 +89,7 @@ static void ColouriseInnoDoc(Sci_PositionU startPos, Sci_Position length, int, W
|
||||
// using the hand-written state machine shown below
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
|
||||
for (Sci_Position i = startPos; i < lengthDoc; i++) {
|
||||
chPrev = ch;
|
||||
ch = chNext;
|
||||
|
||||
@ -1216,6 +1216,8 @@ void LoadSettings()
|
||||
Flags.NoHTMLGuess = IniSectionGetBool(IniSecSettings2, L"NoHTMLGuess", DefaultFlags.NoHTMLGuess);
|
||||
Flags.NoCGIGuess = IniSectionGetBool(IniSecSettings2, L"NoCGIGuess", DefaultFlags.NoCGIGuess);
|
||||
Flags.NoFileVariables = IniSectionGetBool(IniSecSettings2, L"NoFileVariables", DefaultFlags.NoFileVariables);
|
||||
|
||||
Flags.SaveBlankNewFile = IniSectionGetBool(IniSecSettings2, L"SaveBlankNewFile", DefaultFlags.SaveBlankNewFile);
|
||||
|
||||
Flags.PrintFileAndLeave = Globals.CmdLnFlag_PrintFileAndLeave;
|
||||
|
||||
|
||||
@ -779,6 +779,7 @@ static void _InitGlobals()
|
||||
Flags.NoHTMLGuess =DefaultFlags.NoHTMLGuess = false;
|
||||
Flags.NoCGIGuess = DefaultFlags.NoCGIGuess = false;
|
||||
Flags.NoFileVariables = DefaultFlags.NoFileVariables = false;
|
||||
Flags.SaveBlankNewFile = DefaultFlags.SaveBlankNewFile = true;
|
||||
Flags.ShellUseSystemMRU = DefaultFlags.ShellUseSystemMRU = true;
|
||||
Flags.PrintFileAndLeave = DefaultFlags.PrintFileAndLeave = 0;
|
||||
Flags.bPreserveFileModTime = DefaultFlags.bPreserveFileModTime = false;
|
||||
@ -11787,24 +11788,24 @@ bool FileSave(FileSaveFlags fSaveFlags)
|
||||
fioStatus.iEncoding = Encoding_GetCurrent();
|
||||
fioStatus.iEOLMode = SciCall_GetEOLMode();
|
||||
|
||||
#if 0
|
||||
bool bIsEmptyNewFile = false;
|
||||
if (Path_IsEmpty(Paths.CurrentFile)) {
|
||||
DocPos const cchText = SciCall_GetTextLength();
|
||||
if (cchText <= 0) {
|
||||
bIsEmptyNewFile = true;
|
||||
} else if (cchText < 2048) {
|
||||
char chTextBuf[2048] = { '\0' };
|
||||
SciCall_GetText(COUNTOF(chTextBuf) - 1, chTextBuf);
|
||||
StrTrimA(chTextBuf, " \t\n\r");
|
||||
if (StrIsEmptyA(chTextBuf)) {
|
||||
if (Flags.SaveBlankNewFile) {
|
||||
bIsEmptyNewFile = (Path_IsEmpty(Paths.CurrentFile) && (SciCall_GetTextLength() <= 0LL));
|
||||
}
|
||||
else {
|
||||
if (Path_IsEmpty(Paths.CurrentFile)) {
|
||||
DocPos const cchText = SciCall_GetTextLength();
|
||||
if (cchText <= 0) {
|
||||
bIsEmptyNewFile = true;
|
||||
}
|
||||
else {
|
||||
struct Sci_TextToFindFull ft = { { 0, 0 }, "\\S+", { 0, 0 } };
|
||||
ft.chrg.cpMax = Sci_GetDocEndPosition();
|
||||
DocPos const iPos = SciCall_FindTextFull(SCFIND_REGEXP, &ft);
|
||||
bIsEmptyNewFile = ((iPos < 0) || (iPos >= ft.chrg.cpMax));
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
bool const bIsEmptyNewFile = (Path_IsEmpty(Paths.CurrentFile) && (SciCall_GetTextLength() <= 0LL));
|
||||
#endif
|
||||
|
||||
bool const bSaveNeeded = (IsSaveNeeded() || IsFileChangedFlagSet()) && !bIsEmptyNewFile;
|
||||
|
||||
|
||||
@ -722,6 +722,7 @@ typedef struct FLAGS_T {
|
||||
bool RelativeFileMRU;
|
||||
bool PortableMyDocs;
|
||||
bool NoFadeHidden;
|
||||
bool SaveBlankNewFile;
|
||||
bool SimpleIndentGuides;
|
||||
bool NoHTMLGuess;
|
||||
bool NoCGIGuess;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user