]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetListings.cpp
Fix assertion when checking if change in selection
[lyx.git] / src / insets / InsetListings.cpp
index 94abf69b26a6fd266c258f6a072ddaecfa5bd455..ec9ad7225f37254683f45ba25fcc7fa4851d2c7a 100644 (file)
@@ -169,8 +169,20 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
                param_string = getStringFromVector(opts, ",");
        }
        // Minted needs a language specification
-       if (minted_language.empty())
-               minted_language = "TeX";
+       if (minted_language.empty()) {
+               // If a language has been set globally, use that,
+               // otherwise use TeX by default
+               string const & blp = buffer().params().listings_params;
+               size_t start = blp.find("language=");
+               if (start != string::npos) {
+                       start += strlen("language=");
+                       size_t len = blp.find(",", start);
+                       if (len != string::npos)
+                               len -= start;
+                       minted_language = blp.substr(start, len);
+               } else
+                       minted_language = "TeX";
+       }
 
        // get the paragraphs. We can not output them directly to given odocstream
        // because we can not yet determine the delimiter character of \lstinline
@@ -335,7 +347,7 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
                        }
                        os << from_utf8(param_string) << "]\n";
                }
-               os << code  << "\\end{lstlisting}\n";
+               os << code << breakln << "\\end{lstlisting}\n";
        }
 
        if (encoding_switched){