[EU-FOSSA] Enhance the macroable detection to avoid crash

This commit is contained in:
Don HO 2019-02-24 11:34:27 +01:00
parent d7c942ee2f
commit da2d14436c
3 changed files with 27 additions and 15 deletions

View File

@ -54,7 +54,7 @@ void Notepad_plus::macroPlayback(Macro macro)
for (Macro::iterator step = macro.begin(); step != macro.end(); ++step)
{
if (step->isPlayable())
if (step->isScintillaMacro())
step->PlayBack(this->_pPublicInterface, _pEditView);
else
_findReplaceDlg.execSavedCommand(step->_message, step->_lParameter, step->_sParameter);

View File

@ -666,26 +666,34 @@ recordedMacroStep::recordedMacroStep(int iMessage, uptr_t wParam, uptr_t lParam,
// code comes from Scintilla's Editor.cxx:
// void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam)
bool recordedMacroStep::isMacroable(unsigned int iMessage)
bool recordedMacroStep::isMacroable() const
{
// Enumerates all macroable messages
switch (iMessage)
switch (_message)
{
case SCI_REPLACESEL: // (<unused>, const char *text)
case SCI_ADDTEXT: // (int length, const char *s)
case SCI_INSERTTEXT: // (int pos, const char *text)
case SCI_APPENDTEXT: // (int length, const char *s)
case SCI_SEARCHNEXT: // (int searchFlags, const char *text)
case SCI_SEARCHPREV: // (int searchFlags, const char *text)
{
if (_macroType == mtUseSParameter)
return true;
else
return false;
}
case SCI_GOTOLINE: // (int line)
case SCI_GOTOPOS: // (int position)
case SCI_SETSELECTIONMODE: // (int mode)
case SCI_CUT:
case SCI_COPY:
case SCI_PASTE:
case SCI_CLEAR:
case SCI_REPLACESEL:
case SCI_ADDTEXT:
case SCI_INSERTTEXT:
case SCI_APPENDTEXT:
case SCI_CLEARALL:
case SCI_SELECTALL:
case SCI_GOTOLINE:
case SCI_GOTOPOS:
case SCI_SEARCHANCHOR:
case SCI_SEARCHNEXT:
case SCI_SEARCHPREV:
case SCI_LINEDOWN:
case SCI_LINEDOWNEXTEND:
case SCI_PARADOWN:
@ -761,7 +769,6 @@ bool recordedMacroStep::isMacroable(unsigned int iMessage)
case SCI_HOMEDISPLAYEXTEND:
case SCI_LINEENDDISPLAY:
case SCI_LINEENDDISPLAYEXTEND:
case SCI_SETSELECTIONMODE:
case SCI_LINEDOWNRECTEXTEND:
case SCI_LINEUPRECTEXTEND:
case SCI_CHARLEFTRECTEXTEND:
@ -778,7 +785,12 @@ bool recordedMacroStep::isMacroable(unsigned int iMessage)
case SCI_MOVESELECTEDLINESDOWN:
case SCI_SCROLLTOSTART:
case SCI_SCROLLTOEND:
return true;
{
if (_macroType == mtUseLParameter)
return true;
else
return false;
}
// Filter out all others like display changes. Also, newlines are redundant
// with char insert messages.

View File

@ -300,8 +300,8 @@ struct recordedMacroStep {
bool isValid() const {
return true;
};
bool isPlayable() const {return _macroType <= mtMenuCommand;};
bool isMacroable(unsigned int iMessage);
bool isScintillaMacro() const {return _macroType <= mtMenuCommand;};
bool isMacroable() const;
void PlayBack(Window* pNotepad, ScintillaEditView *pEditView);
};