diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 943c0fd8e..2da4db1a0 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -1349,7 +1349,8 @@ describe "EditSession", -> expect(editSession.getSelection().isEmpty()).toBeTruthy() it "does not explode if the current language mode has no comment regex", -> - spyOn(TextMateBundle, 'lineCommentStringForScope').andReturn(null) + editSession.destroy() + editSession = fixturesProject.buildEditSessionForPath(null, autoIndent: false) editSession.setSelectedBufferRange([[4, 5], [4, 5]]) editSession.toggleLineCommentsInSelection() expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {" diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 5a1b857c6..06abe95c7 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -3,7 +3,7 @@ fs = require 'fs' RootView = require 'root-view' Buffer = require 'buffer' Editor = require 'editor' -{View} = require 'space-pen' +{View, $$} = require 'space-pen' describe "RootView", -> rootView = null @@ -161,22 +161,24 @@ describe "RootView", -> expect(rootView.getActiveEditor().isFocused).toBeTruthy() describe "when there is no active editor", -> - describe "when there is a visible focusable element (with a -1 tabindex)", -> - it "passes focus to that element", -> + describe "when are visible focusable elements (with a -1 tabindex)", -> + it "passes focus to the first focusable element", -> rootView.remove() rootView = new RootView(require.resolve 'fixtures') - rootView.activateExtension require('tree-view') - rootView.attachToDom() + rootView.horizontal.append $$ -> + @div "One", id: 'one', tabindex: -1 + @div "Two", id: 'two', tabindex: -1 + + rootView.attachToDom() expect(rootView).not.toMatchSelector(':focus') - expect(rootView.find('.tree-view')).toMatchSelector(':focus') + expect(rootView.find('#one')).toMatchSelector(':focus') + expect(rootView.find('#two')).not.toMatchSelector(':focus') describe "when there are no visible focusable elements", -> it "retains focus itself", -> rootView.remove() rootView = new RootView(require.resolve 'fixtures') - rootView.activateExtension require('tree-view') - rootView.find('.tree-view').hide() rootView.attachToDom() expect(rootView).toMatchSelector(':focus') diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index a3c0af3e9..b0fe94482 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -62,7 +62,7 @@ class RootView extends View false else @setTitle(@project?.getPath()) - focusableChild = this.find("[tabindex=-1]:visible") + focusableChild = this.find("[tabindex=-1]:visible:first") if focusableChild.length focusableChild.focus() false diff --git a/src/app/text-mate-bundle.coffee b/src/app/text-mate-bundle.coffee index d63c57f6f..5cb713b59 100644 --- a/src/app/text-mate-bundle.coffee +++ b/src/app/text-mate-bundle.coffee @@ -41,7 +41,7 @@ class TextMateBundle @lineCommentStringForScope: (scope) -> shellVariables = @getPreferenceInScope(scope, 'shellVariables') - lineComment = (_.find shellVariables, ({name}) -> name == "TM_COMMENT_START")['value'] + (_.find shellVariables, ({name}) -> name == "TM_COMMENT_START")?['value'] @indentRegexForScope: (scope) -> if source = @getPreferenceInScope(scope, 'increaseIndentPattern')