mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
fix properly http://bugzilla.lyx.org/show_bug.cgi?id=2040
* BufferView.cpp (setCursorFromInset): new method, useful to find an inset that is known to be in the document. * frontends/qt4/GuiView.cpp (dispatch): do a proper recordUndo befire appplying changes to an inset. The insets are responsible for recording additional undo steps that could be needed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26428 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9bbe7251af
commit
d585528d50
@ -1742,6 +1742,27 @@ void BufferView::setCursorFromRow(int row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BufferView::setCursorFromInset(Inset const * inset)
|
||||||
|
{
|
||||||
|
// are we already there?
|
||||||
|
if (cursor().nextInset() == inset)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Inset is not at cursor position. Find it in the document.
|
||||||
|
Cursor cur(*this);
|
||||||
|
cur.reset(buffer().inset());
|
||||||
|
do
|
||||||
|
cur.forwardInset();
|
||||||
|
while (cur && cur.nextInset() != inset);
|
||||||
|
|
||||||
|
if (cur) {
|
||||||
|
setCursor(cur);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferView::gotoLabel(docstring const & label)
|
void BufferView::gotoLabel(docstring const & label)
|
||||||
{
|
{
|
||||||
Toc & toc = buffer().tocBackend().toc("label");
|
Toc & toc = buffer().tocBackend().toc("label");
|
||||||
|
@ -144,6 +144,9 @@ public:
|
|||||||
/// set the cursor based on the given TeX source row.
|
/// set the cursor based on the given TeX source row.
|
||||||
void setCursorFromRow(int row);
|
void setCursorFromRow(int row);
|
||||||
|
|
||||||
|
/// set cursor to the given inset. Return true if found.
|
||||||
|
bool setCursorFromInset(Inset const *);
|
||||||
|
|
||||||
/// Ensure that the BufferView cursor is visible.
|
/// Ensure that the BufferView cursor is visible.
|
||||||
/// This method will automatically scroll and update the BufferView
|
/// This method will automatically scroll and update the BufferView
|
||||||
/// if needed.
|
/// if needed.
|
||||||
|
@ -1960,13 +1960,18 @@ bool GuiView::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INSET_APPLY: {
|
case LFUN_INSET_APPLY: {
|
||||||
view()->cursor().recordUndoFullDocument();
|
|
||||||
string const name = cmd.getArg(0);
|
string const name = cmd.getArg(0);
|
||||||
Inset * inset = getOpenInset(name);
|
Inset * inset = getOpenInset(name);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
|
// put cursor in front of inset.
|
||||||
|
if (!view()->setCursorFromInset(inset))
|
||||||
|
LASSERT(false, /**/);
|
||||||
|
|
||||||
|
view()->cursor().recordUndo();
|
||||||
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
|
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
|
||||||
inset->dispatch(view()->cursor(), fr);
|
inset->dispatch(view()->cursor(), fr);
|
||||||
} else {
|
} else {
|
||||||
|
view()->cursor().recordUndo();
|
||||||
FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
|
FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
|
||||||
lyx::dispatch(fr);
|
lyx::dispatch(fr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user