mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
When a tab is clicked, activate its EditSession
This commit is contained in:
@@ -3,7 +3,7 @@ _ = require 'underscore'
|
||||
RootView = require 'root-view'
|
||||
Tabs = require 'tabs'
|
||||
|
||||
fdescribe "Tabs", ->
|
||||
describe "Tabs", ->
|
||||
[rootView, editor, statusBar, buffer, tabs] = []
|
||||
|
||||
beforeEach ->
|
||||
@@ -59,3 +59,11 @@ fdescribe "Tabs", ->
|
||||
editor.destroyActiveEditSession()
|
||||
expect(tabs.find('.tab').length).toBe 1
|
||||
expect(tabs.find('.tab:eq(0) .file-name').text()).toBe 'sample.txt'
|
||||
|
||||
describe "when a tab is clicked", ->
|
||||
it "activates the associated edit session", ->
|
||||
expect(editor.getActiveEditSessionIndex()).toBe 1
|
||||
tabs.find('.tab:eq(0)').click()
|
||||
expect(editor.getActiveEditSessionIndex()).toBe 0
|
||||
tabs.find('.tab:eq(1)').click()
|
||||
expect(editor.getActiveEditSessionIndex()).toBe 1
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
$ = require 'jquery'
|
||||
{View, $$} = require 'space-pen'
|
||||
|
||||
module.exports =
|
||||
@@ -27,6 +28,9 @@ class Tabs extends View
|
||||
@editor.on 'editor:edit-session-added', (e, editSession) => @addTabForEditSession(editSession)
|
||||
@editor.on 'editor:edit-session-removed', (e, editSession, index) => @removeTabAtIndex(index)
|
||||
|
||||
@on 'click', '.tab', (e) =>
|
||||
@editor.setActiveEditSessionIndex($(e.target).closest('.tab').index())
|
||||
|
||||
addTabForEditSession: (editSession) ->
|
||||
@append $$ ->
|
||||
@div class: 'tab', =>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
}
|
||||
|
||||
.tab {
|
||||
cursor: default;
|
||||
float: left;
|
||||
margin: 4px;
|
||||
margin-bottom: 0;
|
||||
|
||||
Reference in New Issue
Block a user