From e2a165cc8e8e5d1d900ab4ede49b2d8a162ce5ba Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 30 Jun 2012 01:30:00 +0000 Subject: [PATCH] [BUG_FIXED] (Author: FLS) Fix wrap/unwrap line position not being kept bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@921 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/NppCommands.cpp | 8 ++++++++ PowerEditor/src/NppNotification.cpp | 12 ++++++++++++ .../src/ScitillaComponent/ScintillaEditView.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index b96bbae3..6a3f9d02 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -1171,6 +1171,14 @@ void Notepad_plus::command(int id) case IDM_VIEW_WRAP: { bool isWraped = !_pEditView->isWrap(); + //--FLS: ViewMoveAtWrappingDisableFix: Disable wrapping messes up visible lines. Therefore save view position before in IDM_VIEW_WRAP and restore after SCN_PAINTED, as Scintilla-Doc. says + if (!isWraped) + { + _mainEditView.saveCurrentPos(); + _mainEditView.setWrapRestoreNeeded(true); + _subEditView.saveCurrentPos(); + _subEditView.setWrapRestoreNeeded(true); + } _mainEditView.wrap(isWraped); _subEditView.wrap(isWraped); _toolBar.setCheck(IDM_VIEW_WRAP, isWraped); diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 6e0f2645..42b1c74c 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -547,6 +547,18 @@ BOOL Notepad_plus::notify(SCNotification *notification) case SCN_PAINTED: { + //--FLS: ViewMoveAtWrappingDisableFix: Disable wrapping messes up visible lines. Therefore save view position before in IDM_VIEW_WRAP and restore after SCN_PAINTED, as doc. says + if (_mainEditView.isWrapRestoreNeeded()) + { + _mainEditView.restoreCurrentPos(); + _mainEditView.setWrapRestoreNeeded(false); + } + + if (_subEditView.isWrapRestoreNeeded()) + { + _subEditView.restoreCurrentPos(); + _subEditView.setWrapRestoreNeeded(false); + } notifyView->updateLineNumberWidth(); if (_syncInfo.doSync()) doSynScorll(HWND(notification->nmhdr.hwndFrom)); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 9176777f..40490de0 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -610,6 +610,8 @@ public: void setHotspotStyle(Style& styleToSet); void setTabSettings(Lang *lang); + bool isWrapRestoreNeeded() const {return _wrapRestoreNeeded;}; + void setWrapRestoreNeeded(bool isWrapRestoredNeeded) {_wrapRestoreNeeded = isWrapRestoredNeeded;}; /* pair getLineUndoState(size_t currentLine) { Buffer * buf = getCurrentBuffer();