mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 21:27:58 +01:00
allow single line :js commands to be source from RC files
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user