Skip to content

Commit

Permalink
Make hard-coded shortcut "Shift-DEL" be abled to be disabled
Browse files Browse the repository at this point in the history
In order to disable the hard-coded shortcut "Shift-DEL" ability (new feature introduced in v8.6) which delete current line while no selection, users must add an empty file named "disableHardCodedShiftDelete.xml", in "%APPDATA%\Notepad++\" directory (or in the Notepad++ installed directory in portable mode) to prevent this behaviour.

Fix notepad-plus-plus#14470, close notepad-plus-plus#14481
  • Loading branch information
donho committed Dec 14, 2023
1 parent aef0438 commit 53b5055
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
31 changes: 27 additions & 4 deletions PowerEditor/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,11 @@ bool NppParameters::load()


std::wstring filePath, filePath2, issueFileName;

//-------------------------------------------------------------//
// nppLogNetworkDriveIssue.xml //
// This empty xml file is optional - user adds this empty file //
// It's for debugging use only //
//-------------------------------------------------------------//
filePath = _nppPath;
issueFileName = nppLogNetworkDriveIssue;
issueFileName += TEXT(".xml");
Expand All @@ -1606,6 +1610,11 @@ bool NppParameters::load()
_doNppLogNetworkDriveIssue = (PathFileExists(filePath2.c_str()) == TRUE);
}

//-------------------------------------------------------------//
// nppLogNulContentCorruptionIssue.xml //
// This empty xml file is optional - user adds this empty file //
// It's for debugging use only //
//-------------------------------------------------------------//
filePath = _nppPath;
issueFileName = nppLogNulContentCorruptionIssue;
issueFileName += TEXT(".xml");
Expand Down Expand Up @@ -1642,14 +1651,28 @@ bool NppParameters::load()
// manually in order to prevent Notepad++ transform column //
// selection into multi-select. //
//-------------------------------------------------------------//
std::wstring enableNoColumn2MultiSelectPath = _userPath;
pathAppend(enableNoColumn2MultiSelectPath, TEXT("noColumnToMultiSelect.xml"));
std::wstring disableColumn2MultiSelectPath = _userPath;
pathAppend(disableColumn2MultiSelectPath, TEXT("noColumnToMultiSelect.xml"));

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

//-------------------------------------------------------------//
// disableHardCodedShiftDelete.xml //
// This empty xml file is optional - user adds this empty file //
// manually in order to prevent hard coded Shift-DEL shortcut //
// delete whole line while no selection. //
//-------------------------------------------------------------//
std::wstring disableHardCodedShiftDeletePath = _userPath;
pathAppend(disableHardCodedShiftDeletePath, TEXT("disableHardCodedShiftDelete.xml"));

if (PathFileExists(disableHardCodedShiftDeletePath.c_str()))
{
_useHardCodedShiftDelete = false;
}

return isAllLaoded;
}

Expand Down
2 changes: 2 additions & 0 deletions PowerEditor/src/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,7 @@ class NppParameters final
bool isSelectFgColorEnabled() const { return _isSelectFgColorEnabled; };
bool isRegForOSAppRestartDisabled() const { return _isRegForOSAppRestartDisabled; };
bool doColumn2MultiSelect() const { return _column2MultiSelect; };
bool useHardCodedShiftDelete() const { return _useHardCodedShiftDelete; };

private:
bool _isAnyShortcutModified = false;
Expand Down Expand Up @@ -1946,6 +1947,7 @@ class NppParameters final
bool _isSelectFgColorEnabled = false;
bool _isRegForOSAppRestartDisabled = false;
bool _column2MultiSelect = true;
bool _useHardCodedShiftDelete = true;

bool _doNppLogNetworkDriveIssue = false;
bool _doNppLogNulContentCorruptionIssue = false;
Expand Down
3 changes: 2 additions & 1 deletion PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,14 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
SHORT shift = GetKeyState(VK_SHIFT);
bool isColumnSelection = (execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN);
bool column2MultSelect = (NppParameters::getInstance()).doColumn2MultiSelect();
bool useHardCodedShiftDelete = (NppParameters::getInstance()).useHardCodedShiftDelete();

if (wParam == VK_DELETE)
{
// 1 shortcut:
// Shift + Delete: without selected text, it will delete the whole line.
//
if ((shift & 0x8000) && !(ctrl & 0x8000) && !(alt & 0x8000) && !hasSelection()) // Shift-DEL & no selection
if ((shift & 0x8000) && !(ctrl & 0x8000) && !(alt & 0x8000) && !hasSelection() && useHardCodedShiftDelete) // Shift-DEL & no selection
{
execute(SCI_LINEDELETE);
return TRUE;
Expand Down

0 comments on commit 53b5055

Please sign in to comment.