From ad76d3396b48a1737e46f5b046d126a653df167a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 16:09:40 +0800 Subject: [PATCH 1/3] :arrow_up: electron@0.34.5 Fix #9584. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1cb27543a..965c2010e 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/atom/atom/issues" }, "license": "MIT", - "electronVersion": "0.34.3", + "electronVersion": "0.34.5", "dependencies": { "async": "0.2.6", "atom-keymap": "^6.1.1", From 8f1c49cb5c7a79156b634d5d6a19523b56f5f5c9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 20 Nov 2015 16:55:38 -0800 Subject: [PATCH 2/3] Merge pull request #9636 from DouweM/unique-title Use unique text editor title in window and tab titles --- .../sample-theme-2/src/js/plugin/main.js | 0 spec/text-editor-spec.coffee | 23 +++++-- spec/workspace-spec.coffee | 6 +- src/text-editor.coffee | 66 +++++++++++-------- src/workspace.coffee | 2 +- 5 files changed, 58 insertions(+), 39 deletions(-) create mode 100644 spec/fixtures/testdir/sample-theme-2/src/js/plugin/main.js diff --git a/spec/fixtures/testdir/sample-theme-2/src/js/plugin/main.js b/spec/fixtures/testdir/sample-theme-2/src/js/plugin/main.js new file mode 100644 index 000000000..e69de29bb diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 39740ebd2..0cee8215a 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -168,7 +168,7 @@ describe "TextEditor", -> buffer.setPath(undefined) expect(editor.getLongTitle()).toBe 'untitled' - it "returns / when opened files has identical file names", -> + it "returns '' when opened files have identical file names", -> editor1 = null editor2 = null waitsForPromise -> @@ -177,10 +177,10 @@ describe "TextEditor", -> atom.workspace.open(path.join('sample-theme-2', 'readme')).then (o) -> editor2 = o runs -> - expect(editor1.getLongTitle()).toBe 'sample-theme-1/readme' - expect(editor2.getLongTitle()).toBe 'sample-theme-2/readme' + expect(editor1.getLongTitle()).toBe "readme \u2014 sample-theme-1" + expect(editor2.getLongTitle()).toBe "readme \u2014 sample-theme-2" - it "or returns /.../ when opened files has identical file names", -> + it "returns '' when opened files have identical file and dir names", -> editor1 = null editor2 = null waitsForPromise -> @@ -189,9 +189,20 @@ describe "TextEditor", -> atom.workspace.open(path.join('sample-theme-2', 'src', 'js', 'main.js')).then (o) -> editor2 = o runs -> - expect(editor1.getLongTitle()).toBe 'sample-theme-1/.../main.js' - expect(editor2.getLongTitle()).toBe 'sample-theme-2/.../main.js' + expect(editor1.getLongTitle()).toBe "main.js \u2014 sample-theme-1/src/js" + expect(editor2.getLongTitle()).toBe "main.js \u2014 sample-theme-2/src/js" + it "returns '' when opened files have identical file and same parent dir name", -> + editor1 = null + editor2 = null + waitsForPromise -> + atom.workspace.open(path.join('sample-theme-2', 'src', 'js', 'main.js')).then (o) -> + editor1 = o + atom.workspace.open(path.join('sample-theme-2', 'src', 'js', 'plugin', 'main.js')).then (o) -> + editor2 = o + runs -> + expect(editor1.getLongTitle()).toBe "main.js \u2014 js" + expect(editor2.getLongTitle()).toBe "main.js \u2014 js/plugin" it "notifies ::onDidChangeTitle observers when the underlying buffer path changes", -> observed = [] diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 5d7343540..71713d83d 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -76,7 +76,7 @@ describe "Workspace", -> expect(editor4.getCursorScreenPosition()).toEqual [2, 4] expect(atom.workspace.getActiveTextEditor().getPath()).toBe editor3.getPath() - expect(document.title).toBe "#{path.basename(editor3.getPath())} - #{atom.project.getPaths()[0]} - Atom" + expect(document.title).toBe "#{path.basename(editor3.getLongTitle())} - #{atom.project.getPaths()[0]} - Atom" describe "where there are no open panes or editors", -> it "constructs the view with no open editors", -> @@ -776,8 +776,8 @@ describe "Workspace", -> applicationDelegate: atom.applicationDelegate, assert: atom.assert.bind(atom) }) workspace2.deserialize(atom.workspace.serialize(), atom.deserializers) - item = atom.workspace.getActivePaneItem() - expect(document.title).toBe "#{item.getTitle()} - #{atom.project.getPaths()[0]} - Atom" + item = workspace2.getActivePaneItem() + expect(document.title).toBe "#{item.getLongTitle()} - #{atom.project.getPaths()[0]} - Atom" workspace2.destroy() describe "document edited status", -> diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 29d56c6c8..a151c9dba 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -581,10 +581,7 @@ class TextEditor extends Model # # Returns a {String}. getTitle: -> - if sessionPath = @getPath() - path.basename(sessionPath) - else - 'untitled' + @getFileName() ? 'untitled' # Essential: Get unique title for display in other parts of the UI, such as # the window title. @@ -593,41 +590,52 @@ class TextEditor extends Model # If the editor's buffer is saved, its unique title is formatted as one # of the following, # * "" when it is the only editing buffer with this file name. - # * "/.../", where the "..." may be omitted - # if the the direct parent directory is already different. + # * "" when other buffers have this file name. # # Returns a {String} getLongTitle: -> - if sessionPath = @getPath() - title = @getTitle() + if @getPath() + fileName = @getFileName() - # find text editors with identical file name. - paths = [] + allPathSegments = [] for textEditor in atom.workspace.getTextEditors() when textEditor isnt this - if textEditor.getTitle() is title - paths.push(textEditor.getPath()) - if paths.length is 0 - return title - fileName = path.basename(sessionPath) + if textEditor.getFileName() is fileName + allPathSegments.push(textEditor.getDirectoryPath().split(path.sep)) - # find the first directory in all these paths that is unique - nLevel = 0 - while (_.some(paths, (apath) -> path.basename(apath) is path.basename(sessionPath))) - sessionPath = path.dirname(sessionPath) - paths = _.map(paths, (apath) -> path.dirname(apath)) - nLevel += 1 + if allPathSegments.length is 0 + return fileName - directory = path.basename sessionPath - if nLevel > 1 - path.join(directory, "...", fileName) - else - path.join(directory, fileName) + ourPathSegments = @getDirectoryPath().split(path.sep) + allPathSegments.push ourPathSegments + + loop + firstSegment = ourPathSegments[0] + + commonBase = _.all(allPathSegments, (pathSegments) -> pathSegments.length > 1 and pathSegments[0] is firstSegment) + if commonBase + pathSegments.shift() for pathSegments in allPathSegments + else + break + + "#{fileName} \u2014 #{path.join(pathSegments...)}" else 'untitled' # Essential: Returns the {String} path of this editor's text buffer. getPath: -> @buffer.getPath() + getFileName: -> + if fullPath = @getPath() + path.basename(fullPath) + else + null + + getDirectoryPath: -> + if fullPath = @getPath() + path.dirname(fullPath) + else + null + # Extended: Returns the {String} character set encoding of this editor's text # buffer. getEncoding: -> @buffer.getEncoding() @@ -678,16 +686,16 @@ class TextEditor extends Model getSaveDialogOptions: -> {} checkoutHeadRevision: -> - if filePath = this.getPath() + if @getPath() checkoutHead = => - @project.repositoryForDirectory(new Directory(path.dirname(filePath))) + @project.repositoryForDirectory(new Directory(@getDirectoryPath())) .then (repository) => repository?.checkoutHeadForEditor(this) if @config.get('editor.confirmCheckoutHeadRevision') @applicationDelegate.confirm message: 'Confirm Checkout HEAD Revision' - detailedMessage: "Are you sure you want to discard all changes to \"#{path.basename(filePath)}\" since the last Git commit?" + detailedMessage: "Are you sure you want to discard all changes to \"#{@getFileName()}\" since the last Git commit?" buttons: OK: checkoutHead Cancel: null diff --git a/src/workspace.coffee b/src/workspace.coffee index 396008201..6088055d1 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -155,7 +155,7 @@ class Workspace extends Model projectPaths = @project.getPaths() ? [] if item = @getActivePaneItem() itemPath = item.getPath?() - itemTitle = item.getTitle?() + itemTitle = item.getLongTitle?() ? item.getTitle?() projectPath = _.find projectPaths, (projectPath) -> itemPath is projectPath or itemPath?.startsWith(projectPath + path.sep) itemTitle ?= "untitled" From 6b44562a22f197815f656639b6cb36d36423c030 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Sun, 10 Jan 2016 23:11:41 +0100 Subject: [PATCH 3/3] :arrow_up: language-go@0.42.0 This version fixes #10272 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 965c2010e..9c74d5c9b 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "language-css": "0.35.0", "language-gfm": "0.81.0", "language-git": "0.10.0", - "language-go": "0.40.0", + "language-go": "0.42.0", "language-html": "0.42.0", "language-hyperlink": "0.15.0", "language-java": "0.16.1",