+ if (!lyxrc.rtl_support
+ // no RTL boundary at paragraph start
+ || pos == 0
+ // if the metrics have not been calculated, then we are not
+ // on screen and can safely ignore issues about boundaries.
+ || !contains(pit))
+ return false;
+
+ ParagraphMetrics & pm = par_metrics_[pit];
+ // no RTL boundary in empty paragraph
+ if (pm.rows().empty())
+ return false;
+
+ pos_type endpos = pm.getRow(pos - 1, false).endpos();
+ pos_type startpos = pm.getRow(pos, false).pos();
+ // no RTL boundary at line start:
+ // abc\n -> toggle to RTL -> abc\n (and not: abc\n|
+ // | | )
+ if (pos == startpos && pos == endpos) // start of cur row, end of prev row