From a018cae2445a1f3393dd69c3252f0e678cc9721a Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 15 Apr 2009 16:42:38 +0000 Subject: [PATCH] Fix bug 5894: Inserting tabs with inline selections. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29245 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetListings.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index d59679b906..e9fd186f12 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -18,6 +18,7 @@ #include "BufferParams.h" #include "Counters.h" #include "Cursor.h" +#include "CutAndPaste.h" #include "DispatchResult.h" #include "Encoding.h" #include "FuncRequest.h" @@ -288,13 +289,17 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd) InsetListings::string2params(to_utf8(cmd.argument()), params()); break; } + case LFUN_INSET_DIALOG_UPDATE: cur.bv().updateDialog("listings", params2string(params())); break; - case LFUN_TAB_INSERT: - if (cur.selection()) { - // If there is a selection, a tab is inserted at the - // beginning of each paragraph. + + case LFUN_TAB_INSERT: { + bool const multi_par_selection = cur.selection() && + cur.selBegin().pit() != cur.selEnd().pit(); + if (multi_par_selection) { + // If there is a multi-paragraph selection, a tab is inserted + // at the beginning of each paragraph. cur.recordUndoSelection(); pit_type const pit_end = cur.selEnd().pit(); for (pit_type pit = cur.selBegin().pit(); pit <= pit_end; pit++) { @@ -312,10 +317,14 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd) // Maybe we shouldn't allow tabs within a line, because they // are not (yet) aligned as one might do expect. cur.recordUndo(); + if (cur.selection()) + cap::cutSelection(cur, false, false); cur.insert(from_ascii("\t")); cur.finishUndo(); } break; + } + case LFUN_TAB_DELETE: if (cur.selection()) { // If there is a selection, a tab (if present) is removed from -- 2.39.2