Fix crash issue on clomn mode editor

If empty column(s) is/are selected in column mode: create a new document
then Alt-Shift + Arrow right key to select, launch colomn mode editor to
insert some number -> NPP crash.

Fixes #2820, Closes #2850
This commit is contained in:
SinghRajenM 2017-01-30 21:38:01 +05:30 committed by Don Ho
parent 1caa457aae
commit 2119b171af
2 changed files with 15 additions and 4 deletions

View File

@ -2765,6 +2765,11 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, int initial, int in
{ {
assert(repeat > 0); assert(repeat > 0);
// If there is no column mode info available, no need to do anything
// If required a message can be shown to user, that select column properly or something similar
// It is just a double check as taken in callee method (in case this method is called from multiple places)
if (cmi.size() <= 0)
return;
// 0000 00 00 : Dec BASE_10 // 0000 00 00 : Dec BASE_10
// 0000 00 01 : Hex BASE_16 // 0000 00 01 : Hex BASE_16
// 0000 00 10 : Oct BASE_08 // 0000 00 10 : Oct BASE_08

View File

@ -158,11 +158,17 @@ INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1) if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1)
{ {
ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo(); ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo();
// If there is no column mode info available, no need to do anything
// If required a message can be shown to user, that select column properly or something similar
if (colInfos.size() > 0)
{
std::sort(colInfos.begin(), colInfos.end(), SortInPositionOrder()); std::sort(colInfos.begin(), colInfos.end(), SortInPositionOrder());
(*_ppEditView)->columnReplace(colInfos, initialNumber, increaseNumber, repeat, format); (*_ppEditView)->columnReplace(colInfos, initialNumber, increaseNumber, repeat, format);
std::sort(colInfos.begin(), colInfos.end(), SortInSelectOrder()); std::sort(colInfos.begin(), colInfos.end(), SortInSelectOrder());
(*_ppEditView)->setMultiSelections(colInfos); (*_ppEditView)->setMultiSelections(colInfos);
} }
}
else else
{ {
auto cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS); auto cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);