1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 11:37:57 +01:00

allow single line :js commands to be source from RC files

This commit is contained in:
Doug Kearns
2007-09-14 04:31:37 +00:00
parent 79bbf87a8e
commit 2209703239

View File

@@ -518,23 +518,27 @@ const vimperator = (function() //{{{
// handle pure javascript files specially
if (filename.search("\.js$") != -1)
{
eval(s);
}
else
{
var heredoc = "";
var heredocEnd = null; // the string which ends the heredoc
var heredoc_end = null; // the string which ends the heredoc
s.split("\n").forEach(function(line)
{
if (heredocEnd) // we already are in a heredoc
if (heredoc_end) // we already are in a heredoc
{
if (line.search(heredocEnd) != -1)
if (heredoc_end.test(line))
{
eval(heredoc);
heredoc = "";
heredocEnd = null;
heredoc_end = null;
}
else
{
heredoc += line + "\n";
}
}
else
{
@@ -544,12 +548,16 @@ const vimperator = (function() //{{{
if (command && command.name == "javascript")
{
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
if (matches && matches[2])
if (matches)
{
heredocEnd = new RegExp("^" + matches[2] + "$", "m");
heredoc_end = new RegExp("^" + matches[2] + "$", "m");
if (matches[1])
heredoc = matches[1] + "\n";
}
else
{
command.execute(args, special, count);
}
}
else
{