X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=3e6fdf0e14e62634173830b242372aa160a48a51;hb=425c190d623daeb6d05bce1aa2244b548225305a;hp=8da40fc7d7f7d2f77f5159a0f5047bf5f42ce9be;hpb=cce4639b557ed9b7f6233948490eb6f9eda90cda;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 8da40fc7d7..3e6fdf0e14 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1548,11 +1548,41 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) while (pos > 0 && par.isDeleted(pos - 1)) --pos; + bool const inner = (cmd.getArg(0) == "single" || cmd.getArg(0) == "inner"); + + // Guess quote side. + // A space triggers an opening quote. This is passed if the preceding + // char/inset is a space or at paragraph start. char_type c = ' '; - 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(*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; cur.insert(new InsetQuotes(cur.buffer(), c, quote_level, cmd.getArg(1), cmd.getArg(2))); cur.buffer()->updateBuffer(); cur.posForward(); @@ -1745,13 +1775,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_HREF_INSERT: { - // FIXME If we're actually given an argument, shouldn't - // we use it, whether or not we have a selection? docstring content = cmd.argument(); - if (cur.selection()) { + if (content.empty() && cur.selection()) content = cur.selectionAsString(false); - cutSelection(cur, true, false); - } InsetCommandParams p(HYPERLINK_CODE); if (!content.empty()){