Last active
May 22, 2019 09:31
-
-
Save knopp/b7db7a1ffe92d36300e313af2ce6d8b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
let prev = require.getConfig().onError; | |
// Weird errors in console - at first attempt require is not able to find the | |
// packages | |
require.getConfig().onError = function (e) { | |
if (e.neededBy != "ourModule") { | |
prev(e); | |
} | |
} | |
// Override function 'name' on where, invoking cb right before the function returns | |
override = function (where, name, cb, processRes) { | |
(function (original) { | |
where.prototype[name] = function () { | |
let res = original.apply(this, arguments); | |
if (cb !== undefined) | |
cb.apply(this); | |
if (processRes !== undefined) | |
res = processRes.apply(this, [res]); | |
return res; | |
} | |
})(where.prototype[name]); | |
} | |
require.define("ourModule", [ | |
"vs/workbench/browser/workbench", | |
"vs/workbench/services/window/electron-browser/windowService", | |
"vs/base/browser/dom", | |
], | |
function (wb, ws, dom) { | |
override(wb.Workbench, "startup", undefined, function (r) { | |
// Intercept to grab the InstantiationService, we'll need it later to | |
// get instance of WindowService | |
window.services = r; | |
return r; | |
}); | |
let needTitle = true; | |
let previousAdd = dom.addDisposableListener; | |
dom.addDisposableListener = function (node, type, handler, useCapture) { | |
// attach handler to sidebar title | |
if (needTitle && document.getElementsByClassName("composite title").length > 0) { | |
document.getElementsByClassName("composite title")[0].addEventListener("dblclick", function () { | |
let windowService = window.services.createInstance(ws.WindowService); | |
windowService.onWindowTitleDoubleClick(); | |
}); | |
needTitle = false; | |
} | |
// override handler for tabs container | |
if (type == "dblclick" && node.className == 'tabs-container') { | |
handler = function () { | |
let windowService = window.services.createInstance(ws.WindowService); | |
windowService.onWindowTitleDoubleClick(); | |
} | |
} | |
return previousAdd(node, type, handler, useCapture); | |
} | |
} | |
); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment