Skip to content

Commit

Permalink
Make column to multi-select be abled to be disabled
Browse files Browse the repository at this point in the history
In order to disable the "Column to multi-select" ability (new feature introduced in v8.6), users must add an empty file named "noColumnToMultiSelect.xml", in "%APPDATA%\Notepad++\" directory (or in the Notepad++ installed directory in portable mode) to prevent this behaviour.

ref: #14296 (comment)

Fix #14464, close #14476
  • Loading branch information
donho committed Dec 13, 2023
1 parent e497ae2 commit aef0438
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
15 changes: 15 additions & 0 deletions PowerEditor/src/Parameters.cpp
Expand Up @@ -1635,6 +1635,21 @@ bool NppParameters::load()
_isRegForOSAppRestartDisabled = (::PathFileExists(filePath.c_str()) == TRUE);
}


//-------------------------------------------------------------//
// noColumnToMultiSelect.xml //
// This empty xml file is optional - user adds this empty file //
// manually in order to prevent Notepad++ transform column //
// selection into multi-select. //
//-------------------------------------------------------------//
std::wstring enableNoColumn2MultiSelectPath = _userPath;
pathAppend(enableNoColumn2MultiSelectPath, TEXT("noColumnToMultiSelect.xml"));

if (PathFileExists(enableNoColumn2MultiSelectPath.c_str()))
{
_column2MultiSelect = false;
}

return isAllLaoded;
}

Expand Down
4 changes: 3 additions & 1 deletion PowerEditor/src/Parameters.h
Expand Up @@ -1877,6 +1877,7 @@ class NppParameters final
bool regexBackward4PowerUser() const { return _findHistory._regexBackward4PowerUser; }
bool isSelectFgColorEnabled() const { return _isSelectFgColorEnabled; };
bool isRegForOSAppRestartDisabled() const { return _isRegForOSAppRestartDisabled; };
bool doColumn2MultiSelect() const { return _column2MultiSelect; };

private:
bool _isAnyShortcutModified = false;
Expand Down Expand Up @@ -1944,10 +1945,11 @@ class NppParameters final

bool _isSelectFgColorEnabled = false;
bool _isRegForOSAppRestartDisabled = false;
bool _column2MultiSelect = true;

bool _doNppLogNetworkDriveIssue = false;

bool _doNppLogNulContentCorruptionIssue = false;

bool _isEndSessionStarted = false;
bool _isEndSessionCritical = false;

Expand Down
7 changes: 4 additions & 3 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Expand Up @@ -524,6 +524,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
SHORT alt = GetKeyState(VK_MENU);
SHORT shift = GetKeyState(VK_SHIFT);
bool isColumnSelection = (execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN);
bool column2MultSelect = (NppParameters::getInstance()).doColumn2MultiSelect();

if (wParam == VK_DELETE)
{
Expand Down Expand Up @@ -610,7 +611,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
}
}
}
else if (isColumnSelection)
else if (isColumnSelection && column2MultSelect)
{
//
// Transform the column selection to multi-edit
Expand All @@ -628,8 +629,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
execute(SCI_SETSELECTIONMODE, SC_SEL_STREAM); // When it's rectangular selection and the arrow keys are pressed, we switch the mode for having multiple carets.

execute(SCI_SETSELECTIONMODE, SC_SEL_STREAM); // the 2nd call for removing the unwanted selection while moving carets.
// Solution suggested by Neil Hodgson. See:
// https://sourceforge.net/p/scintilla/bugs/2412/
// Solution suggested by Neil Hodgson. See:
// https://sourceforge.net/p/scintilla/bugs/2412/
break;

default:
Expand Down

0 comments on commit aef0438

Please sign in to comment.