From 8e43715baf0ecc48acccc83883f66a5430ad8f20 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 20 Nov 2015 18:26:00 +0100 Subject: [PATCH] Fix tab settings not working in javascript When tab settings exists only for L_JS (the old settings) but if the current document is L_JAVASCRIPT, tab settings for L_JS won't apply to L_JAVASCRIPT document. The fix is to use L_JS's tab settings for both L_JS and L_JAVASCRIPT documents, and to synchronize the values of both type while user modifies javascript tab settings. --- .../ScitillaComponent/ScintillaEditView.cpp | 7 ++++++ .../WinControls/Preference/preferenceDlg.cpp | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index b85da9582..bdcca2776 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -3040,6 +3040,13 @@ void ScintillaEditView::setTabSettings(Lang *lang) { if (lang && lang->_tabSize != -1 && lang->_tabSize != 0) { + if (lang->_langID == L_JAVASCRIPT) + { + Lang *ljs = _pParameter->getLangFromID(L_JS); + execute(SCI_SETTABWIDTH, ljs->_tabSize); + execute(SCI_SETUSETABS, !ljs->_isTabReplacedBySpace); + return; + } execute(SCI_SETTABWIDTH, lang->_tabSize); execute(SCI_SETUSETABS, !lang->_isTabReplacedBySpace); } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 070ce59b4..1f757971a 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -1811,6 +1811,17 @@ INT_PTR CALLBACK TabSettings::run_dlgProc(UINT Message, WPARAM wParam, LPARAM/* { Lang *lang = pNppParam->getLangFromIndex(index - 1); if (!lang) return FALSE; + if (lang->_langID == L_JS) + { + Lang *ljs = pNppParam->getLangFromID(L_JAVASCRIPT); + ljs->_tabSize = size; + } + else if (lang->_langID == L_JAVASCRIPT) + { + Lang *ljavascript = pNppParam->getLangFromID(L_JS); + ljavascript->_tabSize = size; + } + lang->_tabSize = size; // write in langs.xml @@ -1836,6 +1847,18 @@ INT_PTR CALLBACK TabSettings::run_dlgProc(UINT Message, WPARAM wParam, LPARAM/* if (!lang) return FALSE; if (!lang->_tabSize || lang->_tabSize == -1) lang->_tabSize = nppGUI._tabSize; + + if (lang->_langID == L_JS) + { + Lang *ljs = pNppParam->getLangFromID(L_JAVASCRIPT); + ljs->_isTabReplacedBySpace = isTabReplacedBySpace; + } + else if (lang->_langID == L_JAVASCRIPT) + { + Lang *ljavascript = pNppParam->getLangFromID(L_JS); + ljavascript->_isTabReplacedBySpace = isTabReplacedBySpace; + } + lang->_isTabReplacedBySpace = isTabReplacedBySpace; // write in langs.xml