]> git.lyx.org Git - features.git/blobdiff - src/Text2.cpp
Update tex2lyx tests
[features.git] / src / Text2.cpp
index f77bfaa3de54f93bd93775206a5105733dd79eb8..3dae072cecfa9e9132d396c16764f7f053f9dd08 100644 (file)
@@ -162,6 +162,7 @@ void Text::setInsetFont(BufferView const & bv, pit_type pit,
 void Text::setLayout(pit_type start, pit_type end,
                     docstring const & layout)
 {
+       // FIXME: make this work in multicell selection case
        LASSERT(start != end, return);
 
        Buffer const & buffer = owner_->buffer();
@@ -426,6 +427,11 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
                cur.top() = resetCursor;
                cur.resetAnchor();
        }
+
+       // if there was no selection at all, the point was to change cursor font.
+       // Otherwise, we want to reset it to local text font.
+       if (cur.selection() || implicitSelection)
+               cur.setCurrentFont();
 }
 
 
@@ -916,6 +922,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
        if (cur.depth() >= old.depth()) {
                CursorSlice & curslice = cur[old.depth() - 1];
                if (&curslice.inset() == &old.inset()
+                   && curslice.idx() == old.idx()
                    && curslice.pit() > old.pit()) {
                        --curslice.pit();
                        // since a paragraph has been deleted, all the
@@ -932,6 +939,15 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
 
 void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges)
+{
+       pos_type last_pos = pars_[last].size() - 1;
+       deleteEmptyParagraphMechanism(first, last, 0, last_pos, trackChanges);
+}
+
+
+void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last,
+                                        pos_type first_pos, pos_type last_pos,
+                                        bool trackChanges)
 {
        LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), return);
 
@@ -942,8 +958,9 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool tra
                 * (1) Delete consecutive spaces
                 */
                if (!par.isFreeSpacing()) {
-                       pos_type from = 0;
-                       while (from < par.size()) {
+                       pos_type from = (pit == first) ? first_pos : 0;
+                       pos_type to_pos = (pit == last) ? last_pos + 1 : par.size();
+                       while (from < to_pos) {
                                // skip non-spaces
                                while (from < par.size()
                                           && (!par.isLineSeparator(from) || par.isDeleted(from)))