mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Inactive tabs change their title when their file is renamed
We were turning off all subscriptions on an edit session from editor when it became inactive. Now we only turn off subscriptions made by the editor, leaving the tab's subscription intact.
This commit is contained in:
@@ -436,15 +436,15 @@ class Editor extends View
|
||||
if @activeEditSession
|
||||
@autosave() if @rootView()?.autosave
|
||||
@saveScrollPositionForActiveEditSession()
|
||||
@activeEditSession.off()
|
||||
@activeEditSession.off(".editor")
|
||||
|
||||
@activeEditSession = @editSessions[index]
|
||||
@activeEditSession.setVisible(true)
|
||||
|
||||
@activeEditSession.on "contents-conflicted", =>
|
||||
@activeEditSession.on "contents-conflicted.editor", =>
|
||||
@showBufferConflictAlert(@activeEditSession)
|
||||
|
||||
@activeEditSession.on "buffer-path-change", =>
|
||||
@activeEditSession.on "buffer-path-change.editor", =>
|
||||
@trigger 'editor-path-change'
|
||||
|
||||
@trigger 'editor-path-change'
|
||||
@@ -745,12 +745,12 @@ class Editor extends View
|
||||
@updateLayerDimensions()
|
||||
@setScrollPositionFromActiveEditSession()
|
||||
|
||||
@activeEditSession.on 'add-selection', (selection) =>
|
||||
@activeEditSession.on 'add-selection.editor', (selection) =>
|
||||
@newCursors.push(selection.cursor)
|
||||
@newSelections.push(selection)
|
||||
@requestDisplayUpdate()
|
||||
|
||||
@activeEditSession.on 'screen-lines-change', (e) => @handleScreenLinesChange(e)
|
||||
@activeEditSession.on 'screen-lines-change.editor', (e) => @handleScreenLinesChange(e)
|
||||
|
||||
@newCursors = @activeEditSession.getCursors()
|
||||
@newSelections = @activeEditSession.getSelections()
|
||||
|
||||
@@ -76,16 +76,22 @@ describe "Tabs", ->
|
||||
expect(editor.getActiveEditSessionIndex()).toBe 1
|
||||
|
||||
describe "when a file name associated with a tab changes", ->
|
||||
[buffer, newPath] = []
|
||||
[buffer, oldPath, newPath] = []
|
||||
|
||||
beforeEach ->
|
||||
buffer = editor.editSessions[0].buffer
|
||||
oldPath = buffer.getPath()
|
||||
newPath = oldPath.replace(/sample.js$/, "foobar.js")
|
||||
oldPath = "/tmp/file-to-rename.txt"
|
||||
newPath = "/tmp/renamed-file.txt"
|
||||
fs.write(oldPath, "this old path")
|
||||
rootView.open(oldPath)
|
||||
|
||||
afterEach ->
|
||||
fs.remove(newPath)
|
||||
fs.remove(newPath) if fs.exists(newPath)
|
||||
|
||||
it "updates the file name in the tab", ->
|
||||
buffer.saveAs(newPath)
|
||||
expect(tabs.find('.tab:first .file-name')).toHaveText "foobar.js"
|
||||
tabFileName = tabs.find('.tab:eq(2) .file-name')
|
||||
expect(tabFileName).toExist()
|
||||
editor.setActiveEditSessionIndex(0)
|
||||
fs.move(oldPath, newPath)
|
||||
waitsFor "file to be renamed", ->
|
||||
tabFileName.text() == "renamed-file.txt"
|
||||
|
||||
@@ -8,7 +8,8 @@ class Tab extends View
|
||||
|
||||
initialize: (@editSession) ->
|
||||
@updateFileName()
|
||||
@editSession.on 'buffer-path-change.tab', => @updateFileName()
|
||||
@editSession.on 'buffer-path-change.tab', =>
|
||||
@updateFileName()
|
||||
|
||||
updateFileName: ->
|
||||
@fileName.text(@editSession.buffer.getBaseName() ? 'untitled')
|
||||
|
||||
Reference in New Issue
Block a user