Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when Atom has no active TextEditor #200

Closed
postcasio opened this issue Jan 7, 2015 · 3 comments
Closed

Error when Atom has no active TextEditor #200

postcasio opened this issue Jan 7, 2015 · 3 comments

Comments

@postcasio
Copy link
Contributor

TypeError: Cannot read property 'id' of undefined
  at Main.module.exports.V4Main.minimapForEditor (/Users/dominic/.atom/packages/minimap/lib/main-v4.coffee:32:56)
  at Main.module.exports.ViewManagement.getActiveMinimap (/Users/dominic/.atom/packages/minimap/lib/mixins/view-management.coffee:38:25)
  at MinimapFindResultsView.getMinimap (/Users/dominic/.atom/packages/minimap-find-and-replace/lib/minimap-find-results-view.coffee:21:35)
  at MinimapFindResultsView.markersUpdated (/Users/dominic/.atom/packages/minimap-find-and-replace/lib/minimap-find-results-view.coffee:24:18)
  at /Users/dominic/.atom/packages/minimap-find-and-replace/lib/minimap-find-results-view.coffee:1:1
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:82:11)
  at FindModel.module.exports.FindModel.destroyAllMarkers (/Applications/Atom.app/Contents/Resources/app/node_modules/find-and-replace/lib/find-model.js:244:20)
  at FindModel.module.exports.FindModel.activePaneItemChanged (/Applications/Atom.app/Contents/Resources/app/node_modules/find-and-replace/lib/find-model.js:50:12)
  at /Applications/Atom.app/Contents/Resources/app/node_modules/find-and-replace/lib/find-model.js:3:61
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:82:11)
  at /Applications/Atom.app/Contents/Resources/app/src/pane-container.js:347:34
  at Pane.module.exports.Pane.observeActiveItem (/Applications/Atom.app/Contents/Resources/app/src/pane.js:160:7)
  at /Applications/Atom.app/Contents/Resources/app/src/pane-container.js:346:42
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:82:11)
  at PaneContainer.module.exports.PaneContainer.setActivePane (/Applications/Atom.app/Contents/Resources/app/src/pane-container.js:218:22)
  at Pane.module.exports.Pane.activate (/Applications/Atom.app/Contents/Resources/app/src/pane.js:582:15)
  at Pane.module.exports.Pane.split (/Applications/Atom.app/Contents/Resources/app/src/pane.js:660:15)
  at Pane.module.exports.Pane.splitRight (/Applications/Atom.app/Contents/Resources/app/src/pane.js:626:19)
  at Pane.module.exports.Pane.findOrCreateRightmostSibling (/Applications/Atom.app/Contents/Resources/app/src/pane.js:688:21)
  at Workspace.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/workspace.js:406:43)
  at Workspace.module.exports.Workspace.open (/Applications/Atom.app/Contents/Resources/app/src/workspace.js:410:12)
  at ProjectFindView.module.exports.ProjectFindView.showResultPane (/Applications/Atom.app/Contents/Resources/app/node_modules/find-and-replace/lib/project-find-view.js:506:29)
  at ProjectFindView.module.exports.ProjectFindView.search (/Applications/Atom.app/Contents/Resources/app/node_modules/find-and-replace/lib/project-find-view.js:424:19)
  at ProjectFindView.module.exports.ProjectFindView.confirm (/Applications/Atom.app/Contents/Resources/app/node_modules/find-and-replace/lib/project-find-view.js:406:28)
  at space-pen-div.subscriptions.add.atom.commands.add.core:confirm (/Applications/Atom.app/Contents/Resources/app/node_modules/find-and-replace/lib/project-find-view.js:227:26)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:243:29)
  at /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:549:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:391:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:167:20)

V4, when trying to find in project, this exception is thrown. It's caused by Workspace::getActiveTextEditor returning undefined. The existential operator is supposed to check for null and undefined but it appears to be compiling to only a check for null.

  minimapForEditor: (editor) ->
    @minimapViews[editor.id] if editor?

Compiles to this JS:

    ViewManagement.prototype.minimapForEditor = function(editor) {
      if (editor != null) {
        return this.minimapViews[editor.id];
      }
    };
@postcasio
Copy link
Contributor Author

Further investigation has confused me more. undefined != null is false in JS. So I'm not sure what's happening.

@abe33
Copy link
Contributor

abe33 commented Jan 7, 2015

Yes I got that one too, in fact the code for the minimapForEditor method in v4 version is in the main-v4 mixin file (I inject it at activation if the setting is true, hence the need for restart), I may have omitted to add the existence check in it.

I'll fix that asap

@postcasio
Copy link
Contributor Author

Oops, I read the stack trace but completely forgot it was in main-v4 when I was looking :)

@abe33 abe33 closed this as completed in 01b2bc8 Jan 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants