- if (pos > 0 && (!cur.prevInset() || !cur.prevInset()->isSpace()))
- c = par.getChar(pos - 1);
- InsetQuotes::QuoteLevel const quote_level = (cmd.getArg(0) == "single")
- ? InsetQuotes::SingleQuotes : InsetQuotes::DoubleQuotes;
+ if (pos > 0 && !par.isSpace(pos - 1)) {
+ if (cur.prevInset() && cur.prevInset()->lyxCode() == QUOTE_CODE) {
+ // If an opening double quotation mark precedes, and this
+ // is a single quote, make it opening as well
+ InsetQuotes & ins =
+ static_cast<InsetQuotes &>(*cur.prevInset());
+ string const type = ins.getType();
+ if (!suffixIs(type, "ld") || !inner)
+ c = par.getChar(pos - 1);
+ }
+ else if (!cur.prevInset()
+ || (cur.prevInset() && cur.prevInset()->isChar()))
+ // If a char precedes, pass that and let InsetQuote decide
+ c = par.getChar(pos - 1);
+ else {
+ while (pos > 0) {
+ if (par.getInset(pos - 1)
+ && !par.getInset(pos - 1)->isPartOfTextSequence()) {
+ // skip "invisible" insets
+ --pos;
+ continue;
+ }
+ c = par.getChar(pos - 1);
+ break;
+ }
+ }
+ }
+ InsetQuotesParams::QuoteLevel const quote_level = inner
+ ? InsetQuotesParams::SecondaryQuotes : InsetQuotesParams::PrimaryQuotes;