Fix new document number jumps from "New 1" to "New 3" issue
Solution from: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/13931#issuecomment-1653523758 Fix #13194, fix #8677, close #13960pull/13974/head
parent
dea388bf59
commit
fdae99e6c0
|
@ -7788,6 +7788,7 @@ static const QuoteParams quotes[] =
|
|||
{TEXT("Anonymous #203"), QuoteParams::rapid , false, SC_CP_UTF8, L_TEXT, TEXT("My gynecologist follows me on Instagram, I really do not know what else he want to see.\n\n") },
|
||||
{TEXT("Anonymous #204"), QuoteParams::slow , false, SC_CP_UTF8, L_TEXT, TEXT("The greatest security vulnerability in any computer system is located between the keyboard and the chair.\n\n") },
|
||||
{TEXT("Anonymous #205"), QuoteParams::slow , false, SC_CP_UTF8, L_TEXT, TEXT("Courage is knowing it might hurt, and doing it anyway.\nStupidity is the same.\nAnd that's why life is hard.\n\n") },
|
||||
{TEXT("Anonymous #206"), QuoteParams::rapid , false, SC_CP_UTF8, L_TEXT, TEXT("RegEx can save 30 minutes of your dev time with only 10 characters.\nBut you have to spend more than 40 minutes to figure out what these 10 characters need to be.\n\n") },
|
||||
{TEXT("xkcd"), QuoteParams::rapid, false, SC_CP_UTF8, L_TEXT, TEXT("Never have I felt so close to another soul\nAnd yet so helplessly alone\nAs when I Google an error\nAnd there's one result\nA thread by someone with the same problem\nAnd no answer\nLast posted to in 2003\n\n\"Who were you, DenverCoder9?\"\n\"What did you see?!\"\n\n(ref: https://xkcd.com/979/)") },
|
||||
{TEXT("A developer"), QuoteParams::slow, false, SC_CP_UTF8, L_TEXT, TEXT("No hugs & kisses.\nOnly bugs & fixes.") },
|
||||
{TEXT("Elon Musk"), QuoteParams::rapid, false, SC_CP_UTF8, L_TEXT, TEXT("Don't set your password as your child's name.\nName your child after your password.") },
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
#define MENU 0x01
|
||||
#define TOOLBAR 0x02
|
||||
|
||||
#define MAIN_EDIT_ZONE true
|
||||
|
||||
enum FileTransferMode {
|
||||
TransferClone = 0x01,
|
||||
TransferMove = 0x02
|
||||
|
@ -278,8 +280,8 @@ private:
|
|||
DocTabView* _pDocTab = nullptr;
|
||||
DocTabView* _pNonDocTab = nullptr;
|
||||
|
||||
ScintillaEditView _subEditView;
|
||||
ScintillaEditView _mainEditView;
|
||||
ScintillaEditView _subEditView = ScintillaEditView(MAIN_EDIT_ZONE); // only _mainEditView and _subEditView are MAIN_EDIT_ZONE comparing with other Scintilla controls
|
||||
ScintillaEditView _mainEditView = ScintillaEditView(MAIN_EDIT_ZONE); // only _mainEditView and _subEditView are MAIN_EDIT_ZONE comparing with other Scintilla controls
|
||||
ScintillaEditView _invisibleEditView; // for searches
|
||||
ScintillaEditView _fileEditView; // for FileManager
|
||||
ScintillaEditView* _pEditView = nullptr;
|
||||
|
|
|
@ -1329,13 +1329,19 @@ BufferID FileManager::newEmptyDocument()
|
|||
return id;
|
||||
}
|
||||
|
||||
BufferID FileManager::bufferFromDocument(Document doc)
|
||||
BufferID FileManager::bufferFromDocument(Document doc, bool isMainEditZone)
|
||||
{
|
||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||
generic_string newTitle = (nppParamInst.getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR);
|
||||
TCHAR nb[10];
|
||||
wsprintf(nb, TEXT("%d"), static_cast<int>(nextUntitledNewNumber()));
|
||||
newTitle += nb;
|
||||
std::wstring newTitle = L"newNonMainEditZoneInvisibleTitle "; // This title is invisible for "Document map", "Find result" or other Scintilla controls other than _mainEditView and _subEditView.
|
||||
// Its strong length and the space at the end are for preventing the tab name modification from the collision with it.
|
||||
|
||||
if (isMainEditZone) // only _mainEditView or _subEditView is main edit zone, so we count new number of doc only for these 2 scintilla edit views.
|
||||
{
|
||||
newTitle = (nppParamInst.getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR);
|
||||
wchar_t nb[10];
|
||||
wsprintf(nb, TEXT("%d"), static_cast<int>(nextUntitledNewNumber()));
|
||||
newTitle += nb;
|
||||
}
|
||||
|
||||
Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str(), false);
|
||||
BufferID id = newBuf;
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
BufferID newEmptyDocument();
|
||||
|
||||
//create Buffer from existing Scintilla, used from new Scintillas.
|
||||
BufferID bufferFromDocument(Document doc);
|
||||
BufferID bufferFromDocument(Document doc, bool isMainEditZone);
|
||||
|
||||
BufferID getBufferFromName(const TCHAR * name);
|
||||
BufferID getBufferFromDocument(Document doc);
|
||||
|
|
|
@ -1881,7 +1881,7 @@ BufferID ScintillaEditView::attachDefaultDoc()
|
|||
// get the doc pointer attached (by default) on the view Scintilla
|
||||
Document doc = execute(SCI_GETDOCPOINTER, 0, 0);
|
||||
execute(SCI_ADDREFDOCUMENT, 0, doc);
|
||||
BufferID id = MainFileManager.bufferFromDocument(doc);
|
||||
BufferID id = MainFileManager.bufferFromDocument(doc, _isMainEditZone);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
|
||||
MainFileManager.addBufferReference(id, this); //add a reference. Notepad only shows the buffer in tabbar
|
||||
|
|
|
@ -309,6 +309,11 @@ public:
|
|||
ScintillaEditView(): Window() {
|
||||
++_refCount;
|
||||
};
|
||||
|
||||
ScintillaEditView(bool isMainEditZone) : Window() {
|
||||
_isMainEditZone = isMainEditZone;
|
||||
++_refCount;
|
||||
};
|
||||
|
||||
virtual ~ScintillaEditView()
|
||||
{
|
||||
|
@ -782,6 +787,7 @@ protected:
|
|||
static LRESULT CALLBACK scintillaStatic_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
bool _isMainEditZone = false;
|
||||
SCINTILLA_FUNC _pScintillaFunc = nullptr;
|
||||
SCINTILLA_PTR _pScintillaPtr = nullptr;
|
||||
static WNDPROC _scintillaDefaultProc;
|
||||
|
|
Loading…
Reference in New Issue