-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrails-stacktrace-mvim.user.js
More file actions
32 lines (27 loc) · 1.08 KB
/
rails-stacktrace-mvim.user.js
File metadata and controls
32 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ==UserScript==
// @name Rails Stacktrace TextMate Linker
// @namespace https://github.com/ketan/chrome-plugins
// @description make your stack trace lines open in TextMate
// @match http://localhost/*
// @match https://localhost/*
// ==/UserScript==
if (nodes = document.getElementById("traces") && document.querySelectorAll("#traces pre>code")) {
var railsRoot;
var possibleRoots = document.getElementsByTagName('code');
for (var i = 0; i < possibleRoots.length; i++){
var root = possibleRoots[i].innerHTML;
if (root.match(/Rails.root/)){
railsRoot = root.replace('Rails.root: ', '');
}
}
for (var i=0, node; node = nodes[i++];) {
var newHtml = [],
lines = node.innerHTML.split(/\n/);
for (var i=0, line; line = lines[i]; i++){
var parts = line.split(":in ");
var pathAndLine = parts[0].split(":");
newHtml.push("<a href='mvim://open?url=file://", railsRoot , '/', pathAndLine[0], "&line=", pathAndLine[1], "&column=1'>", line, "</a>\n");
}
node.innerHTML = newHtml.join("");
}
}