From 4fa6f631a9d0a0867fa92cecd6fa91d0529ca1be Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 4 Sep 2014 11:03:14 -0700 Subject: [PATCH] Defer ContextMenu require until requested --- src/browser/atom-window.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/browser/atom-window.coffee b/src/browser/atom-window.coffee index 1022f6f76..a2736077a 100644 --- a/src/browser/atom-window.coffee +++ b/src/browser/atom-window.coffee @@ -1,5 +1,4 @@ BrowserWindow = require 'browser-window' -ContextMenu = require './context-menu' app = require 'app' dialog = require 'dialog' path = require 'path' @@ -73,6 +72,13 @@ class AtomWindow getInitialPath: -> @browserWindow.loadSettings.initialPath + setupContextMenu: -> + ContextMenu = null + + @browserWindow.on 'context-menu', (menuTemplate) => + ContextMenu ?= require './context-menu' + new ContextMenu(menuTemplate, this) + containsPath: (pathToCheck) -> initialPath = @getInitialPath() if not initialPath @@ -114,8 +120,7 @@ class AtomWindow when 0 then @browserWindow.destroy() when 1 then @browserWindow.restart() - @browserWindow.on 'context-menu', (menuTemplate) => - new ContextMenu(menuTemplate, this) + @setupContextMenu() if @isSpec # Workaround for https://github.com/atom/atom-shell/issues/380