mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Do not sanitize the anchor of cursor when selection is not set
Additionally, move the code to write to a stream from Cursor to CursorData (so that debugging undo is easier). We loose x_target, but I am not sure it is important. This is the second part of bug #9432.
This commit is contained in:
parent
17e435c47e
commit
97c6e6d1ba
@ -261,6 +261,36 @@ CursorData::CursorData(DocIterator const & dit)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
||||
ostream & operator<<(ostream & os, CursorData const & cur)
|
||||
{
|
||||
os << "\n cursor: | anchor:\n";
|
||||
for (size_t i = 0, n = cur.depth(); i != n; ++i) {
|
||||
os << " " << cur[i] << " | ";
|
||||
if (i < cur.anchor_.depth())
|
||||
os << cur.anchor_[i];
|
||||
else
|
||||
os << "-------------------------------";
|
||||
os << "\n";
|
||||
}
|
||||
for (size_t i = cur.depth(), n = cur.anchor_.depth(); i < n; ++i) {
|
||||
os << "------------------------------- | " << cur.anchor_[i] << "\n";
|
||||
}
|
||||
os << " selection: " << cur.selection_
|
||||
// << " x_target: " << cur.x_target_
|
||||
<< " boundary: " << cur.boundary() << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
LyXErr & operator<<(LyXErr & os, CursorData const & cur)
|
||||
{
|
||||
os.stream() << cur;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// be careful: this is called from the bv's constructor, too, so
|
||||
// bv functions are not yet available!
|
||||
Cursor::Cursor(BufferView & bv)
|
||||
@ -1291,36 +1321,6 @@ bool Cursor::selHandle(bool sel)
|
||||
setSelection(sel);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ostream & operator<<(ostream & os, Cursor const & cur)
|
||||
{
|
||||
os << "\n cursor: | anchor:\n";
|
||||
for (size_t i = 0, n = cur.depth(); i != n; ++i) {
|
||||
os << " " << cur[i] << " | ";
|
||||
if (i < cur.anchor_.depth())
|
||||
os << cur.anchor_[i];
|
||||
else
|
||||
os << "-------------------------------";
|
||||
os << "\n";
|
||||
}
|
||||
for (size_t i = cur.depth(), n = cur.anchor_.depth(); i < n; ++i) {
|
||||
os << "------------------------------- | " << cur.anchor_[i] << "\n";
|
||||
}
|
||||
os << " selection: " << cur.selection_
|
||||
<< " x_target: " << cur.x_target_
|
||||
<< " boundary: " << cur.boundary() << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
LyXErr & operator<<(LyXErr & os, Cursor const & cur)
|
||||
{
|
||||
os.stream() << cur;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
||||
@ -2350,7 +2350,10 @@ void Cursor::sanitize()
|
||||
{
|
||||
setBuffer(&bv_->buffer());
|
||||
DocIterator::sanitize();
|
||||
anchor_.sanitize();
|
||||
if (selection())
|
||||
anchor_.sanitize();
|
||||
else
|
||||
resetAnchor();
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,6 +88,10 @@ public:
|
||||
explicit CursorData(Buffer * buffer);
|
||||
///
|
||||
explicit CursorData(DocIterator const & dit);
|
||||
/// output
|
||||
friend std::ostream & operator<<(std::ostream & os, CursorData const & cur);
|
||||
friend LyXErr & operator<<(LyXErr & os, CursorData const & cur);
|
||||
|
||||
protected:
|
||||
/// the anchor position
|
||||
DocIterator anchor_;
|
||||
@ -345,10 +349,6 @@ public:
|
||||
/// for stable iterators or Undo data.
|
||||
void sanitize();
|
||||
|
||||
/// output
|
||||
friend std::ostream & operator<<(std::ostream & os, Cursor const & cur);
|
||||
friend LyXErr & operator<<(LyXErr & os, Cursor const & cur);
|
||||
|
||||
///
|
||||
bool textUndo();
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user