From 0e082878f3956a8fc8c0a0713566692ae96a7aa4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 13:15:33 -0800 Subject: [PATCH 01/13] Close window on meta-W --- spec/app/window-spec.coffee | 7 ++++++- src/app/keymaps/atom.cson | 1 + src/app/window.coffee | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/app/window-spec.coffee b/spec/app/window-spec.coffee index 9cd9103b2..316f480c8 100644 --- a/spec/app/window-spec.coffee +++ b/spec/app/window-spec.coffee @@ -11,11 +11,16 @@ describe "Window", -> $(window).off 'beforeunload' describe ".close()", -> - it "is triggered by the 'close' event", -> + it "is triggered by the 'core:close' event", -> spyOn window, 'close' $(window).trigger 'core:close' expect(window.close).toHaveBeenCalled() + it "is triggered by the 'window:close event'", -> + spyOn window, 'close' + $(window).trigger 'window:close' + expect(window.close).toHaveBeenCalled() + describe ".reload()", -> it "returns false when no buffers are modified", -> spyOn($native, "reload") diff --git a/src/app/keymaps/atom.cson b/src/app/keymaps/atom.cson index afbd7f049..76cc697c6 100644 --- a/src/app/keymaps/atom.cson +++ b/src/app/keymaps/atom.cson @@ -23,6 +23,7 @@ 'pagedown': 'core:page-down' 'meta-S': 'window:save-all' + 'meta-W': 'window:close' 'meta-+': 'window:increase-font-size' 'meta--': 'window:decrease-font-size' 'ctrl-w w': 'window:focus-next-pane' diff --git a/src/app/window.coffee b/src/app/window.coffee index 7e306f44f..23e4dbb36 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -29,6 +29,7 @@ windowAdditions = @pasteboard = new Pasteboard $(window).on 'core:close', => @close() + $(window).command 'window:close', => @close() # This method is intended only to be run when starting a normal application # Note: RootView assigns itself on window on initialization so that From 1f1e0aac7810d357436ed7ff8a829c9a7274c270 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 13:57:57 -0800 Subject: [PATCH 02/13] Include window events in event-palette Previously these weren't displayed since event the documentation loop stopped at the document element and window events weren't included even though they are applicable for the currently focused element. --- .../event-palette/spec/event-palette-spec.coffee | 14 ++++++++++++++ .../event-palette/src/event-palette.coffee | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/packages/event-palette/spec/event-palette-spec.coffee b/src/packages/event-palette/spec/event-palette-spec.coffee index 53e8448ee..44dd5bb6b 100644 --- a/src/packages/event-palette/spec/event-palette-spec.coffee +++ b/src/packages/event-palette/spec/event-palette-spec.coffee @@ -30,6 +30,20 @@ describe "EventPalette", -> else expect(eventLi).not.toExist() + it "displays all events registerd on the window", -> + editorEvents = rootView.getActiveEditor().events() + windowEvents = $(window).events() + expect(_.isEmpty(windowEvents)).toBeFalsy() + for eventName, description of windowEvents + eventLi = palette.list.children("[data-event-name='#{eventName}']") + description = editorEvents[eventName] unless description + if description + expect(eventLi).toExist() + expect(eventLi.find('.event-name')).toHaveText(eventName) + expect(eventLi.find('.event-description')).toHaveText(description) + else + expect(eventLi).not.toExist() + it "focuses the mini-editor and selects the first event", -> expect(palette.miniEditor.isFocused).toBeTruthy() expect(palette.find('.event:first')).toHaveClass 'selected' diff --git a/src/packages/event-palette/src/event-palette.coffee b/src/packages/event-palette/src/event-palette.coffee index 071f67edc..9e34b797e 100644 --- a/src/packages/event-palette/src/event-palette.coffee +++ b/src/packages/event-palette/src/event-palette.coffee @@ -28,7 +28,7 @@ class EventPalette extends SelectList @keyBindings = _.losslessInvert(keymap.bindingsForElement(@previouslyFocusedElement)) events = [] - for eventName, eventDescription of @previouslyFocusedElement.events() + for eventName, eventDescription of _.extend($(window).events(), @previouslyFocusedElement.events()) events.push({eventName, eventDescription}) if eventDescription events = _.sortBy events, (e) -> e.eventDescription From b43c756820a0cdb9dc145c92aae28b90841318fa Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 14:26:53 -0800 Subject: [PATCH 03/13] Only deactivate the RootView once during shutdown Previously window.shutdown() was called multiple times if window.close() was called since the shutdown handler was also fired in the native window controller. This prevented proper serialization of the RootView from occurring when then window was closed via meta-w or meta-W since it was called a second time when already empty of packages and editors. --- spec/app/window-spec.coffee | 14 +++++++++++++- src/app/window.coffee | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/spec/app/window-spec.coffee b/spec/app/window-spec.coffee index 316f480c8..2471d6cc3 100644 --- a/spec/app/window-spec.coffee +++ b/spec/app/window-spec.coffee @@ -2,8 +2,11 @@ $ = require 'jquery' fs = require 'fs' describe "Window", -> + [rootView] = [] + beforeEach -> window.attachRootView(require.resolve('fixtures')) + rootView = window.rootView afterEach -> window.shutdown() @@ -68,7 +71,7 @@ describe "Window", -> expect(atom.getRootViewStateForPath(window.rootView.project.getPath())).toBeUndefined() expectedState = JSON.parse(JSON.stringify(window.rootView.serialize())) # JSON.stringify removes keys with undefined values $(window).trigger 'beforeunload' - expect(atom.getRootViewStateForPath(window.rootView.project.getPath())).toEqual expectedState + expect(atom.getRootViewStateForPath(rootView.project.getPath())).toEqual expectedState it "unsubscribes from all buffers", -> rootView.open('sample.js') @@ -79,3 +82,12 @@ describe "Window", -> $(window).trigger 'beforeunload' expect(editor1.getBuffer().subscriptionCount()).toBe 0 + + describe ".shutdown()", -> + it "only deactivates the RootView the first time it is called", -> + deactivateSpy = spyOn(rootView, "deactivate").andCallThrough() + window.shutdown() + expect(rootView.deactivate).toHaveBeenCalled() + deactivateSpy.reset() + window.shutdown() + expect(rootView.deactivate).not.toHaveBeenCalled() diff --git a/src/app/window.coffee b/src/app/window.coffee index 23e4dbb36..85077e84a 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -47,7 +47,8 @@ windowAdditions = false shutdown: -> - @rootView.deactivate() + @rootView?.deactivate() + @rootView = null $(window).unbind('focus') $(window).unbind('blur') $(window).off('before') From 5ded74b3e628d72c7eed709ea6b6ddfd7843e472 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 15:41:08 -0800 Subject: [PATCH 04/13] Close inactive editor sessions on alt-meta-w --- spec/app/editor-spec.coffee | 16 ++++++++++++++++ src/app/editor.coffee | 9 +++++++++ src/app/keymaps/editor.cson | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index fed7b5e59..143d82bf1 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2042,3 +2042,19 @@ describe "Editor", -> event.shiftKey = true editor.underlayer.trigger event expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [12,2]] + + describe ".destroyInactiveEditSessions()", -> + it "destroys all non-active, non-modified edit sessions", -> + editor.setText("I'm dirty") + dirtySession = editor.activeEditSession + rootView.open('sample.txt') + cssSession = rootView.open('css.css') + rootView.open('coffee.coffee') + rootView.open('hello.rb') + expect(editor.getEditSessions().length).toBe 5 + editor.setActiveEditSessionIndex(2) + editor.destroyInactiveEditSessions() + expect(editor.getActiveEditSessionIndex()).toBe 1 + expect(editor.getEditSessions().length).toBe 2 + expect(editor.getEditSessions()[0]).toBe dirtySession + expect(editor.getEditSessions()[1]).toBe cssSession diff --git a/src/app/editor.coffee b/src/app/editor.coffee index b4a88884f..a0fb1fcdb 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -176,6 +176,7 @@ class Editor extends View 'editor:toggle-line-comments': @toggleLineCommentsInSelection 'editor:log-cursor-scope': @logCursorScope 'editor:checkout-head-revision': @checkoutHead + 'editor:close-other-editors': @destroyInactiveEditSessions documentation = {} for name, method of editorBindings @@ -457,6 +458,14 @@ class Editor extends View editSession.destroy() @trigger 'editor:edit-session-removed', [editSession, index] + destroyInactiveEditSessions: -> + index = 0 + while session = @editSessions[index] + if @activeEditSession is session or session.buffer.isModified() + index++ + else + @destroyEditSessionIndex(index) + loadNextEditSession: -> nextIndex = (@getActiveEditSessionIndex() + 1) % @editSessions.length @setActiveEditSessionIndex(nextIndex) diff --git a/src/app/keymaps/editor.cson b/src/app/keymaps/editor.cson index cb3675501..78be6a273 100644 --- a/src/app/keymaps/editor.cson +++ b/src/app/keymaps/editor.cson @@ -4,7 +4,6 @@ 'meta-enter': 'editor:newline-below' 'tab': 'editor:indent' 'meta-d': 'editor:delete-line' - 'alt-meta-w': 'editor:toggle-soft-wrap' 'ctrl-[': 'editor:fold-current-row' 'ctrl-]': 'editor:unfold-current-row' 'ctrl-{': 'editor:fold-all' @@ -33,3 +32,4 @@ 'meta-alt-p': 'editor:log-cursor-scope' 'meta-u': 'editor:upper-case' 'meta-U': 'editor:lower-case' + 'alt-meta-w': 'editor:close-other-editors' From 0adae3c634e9dd1b691bbd502743aafbf6c27b05 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 16:24:51 -0800 Subject: [PATCH 05/13] Prompt to save dirty buffers from destroyEditSessionIndex Previously only the active editor session was prompting to save dirty buffers before closing. This caused the confirm dialog to not display when closing from a tab since the Editor.destroyEditSessionIndex is used there. --- spec/app/editor-spec.coffee | 11 +++++++++ src/app/editor.coffee | 45 ++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 143d82bf1..5641c5cf1 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2043,6 +2043,17 @@ describe "Editor", -> editor.underlayer.trigger event expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [12,2]] + describe ".destroyEditSessionIndex(index)", -> + it "prompts to save dirty buffers before closing", -> + editor.setText("I'm dirty") + rootView.open('sample.txt') + expect(editor.getEditSessions().length).toBe 2 + spyOn(atom, "confirm") + editor.destroyEditSessionIndex(0) + expect(atom.confirm).toHaveBeenCalled + expect(editor.getEditSessions().length).toBe 2 + expect(editor.getEditSessions()[0].buffer.isModified()).toBeTruthy() + describe ".destroyInactiveEditSessions()", -> it "destroys all non-active, non-modified edit sessions", -> editor.setText("I'm dirty") diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a0fb1fcdb..3cbc9577f 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -148,7 +148,7 @@ class Editor extends View 'core:select-down': @selectDown 'core:select-to-top': @selectToTop 'core:select-to-bottom': @selectToBottom - 'core:close': @close + 'core:close': @destroyActiveEditSession 'editor:save': @save 'editor:newline-below': @insertNewlineBelow 'editor:toggle-soft-tabs': @toggleSoftTabs @@ -448,15 +448,21 @@ class Editor extends View @destroyEditSessionIndex(@getActiveEditSessionIndex()) destroyEditSessionIndex: (index) -> - if @editSessions.length == 1 - @remove() - else - editSession = @editSessions[index] + return if @mini + + editSession = @editSessions[index] + destroySession = => if index is @getActiveEditSessionIndex() @loadPreviousEditSession() _.remove(@editSessions, editSession) editSession.destroy() @trigger 'editor:edit-session-removed', [editSession, index] + @remove() if @editSessions.length is 0 + + if editSession.buffer.isModified() + @promptToSaveDirtySession(editSession, destroySession) + else + destroySession(editSession) destroyInactiveEditSessions: -> index = 0 @@ -634,14 +640,14 @@ class Editor extends View @removeClass 'soft-wrap' $(window).off 'resize', @_setSoftWrapColumn - save: (onSuccess) -> + save: (session=@activeEditSession, onSuccess) -> if @getPath() - @activeEditSession.save() + session.save() onSuccess?() else atom.showSaveDialog (path) => if path - @activeEditSession.saveAs(path) + session.saveAs(path) onSuccess?() autosave: -> @@ -679,19 +685,16 @@ class Editor extends View rootView: -> @parents('#root-view').view() - close: -> - return if @mini - if @getBuffer().isModified() - filename = if @getPath() then fs.base(@getPath()) else "untitled buffer" - atom.confirm( - "'#{filename}' has changes, do you want to save them?" - "Your changes will be lost if you don't save them" - "Save", (=> @save(=> @destroyActiveEditSession())), - "Cancel", null - "Don't save", (=> @destroyActiveEditSession()) - ) - else - @destroyActiveEditSession() + promptToSaveDirtySession: (session, callback) -> + path = session.getPath() + filename = if path then fs.base(path) else "untitled buffer" + atom.confirm( + "'#{filename}' has changes, do you want to save them?" + "Your changes will be lost if you don't save them" + "Save", => @save(session, callback), + "Cancel", null + "Don't save", callback + ) remove: (selector, keepData) -> return super if keepData From ebe7ff7090fba272c474b3aff4bb869f00c586c0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 16:47:32 -0800 Subject: [PATCH 06/13] Destroy inactive editor sessions that are dirty A confirm dialog is now displayed whenever a session with a dirty buffer is closed so dirty sessions can now be processed when 'editor:close-other-tabs' is fired. --- spec/app/editor-spec.coffee | 22 +++++++++++++++------- src/app/editor.coffee | 16 +++++++--------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 5641c5cf1..1542a6641 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2050,14 +2050,12 @@ describe "Editor", -> expect(editor.getEditSessions().length).toBe 2 spyOn(atom, "confirm") editor.destroyEditSessionIndex(0) - expect(atom.confirm).toHaveBeenCalled + expect(atom.confirm).toHaveBeenCalled() expect(editor.getEditSessions().length).toBe 2 expect(editor.getEditSessions()[0].buffer.isModified()).toBeTruthy() describe ".destroyInactiveEditSessions()", -> - it "destroys all non-active, non-modified edit sessions", -> - editor.setText("I'm dirty") - dirtySession = editor.activeEditSession + it "destroys every edit session except the active one", -> rootView.open('sample.txt') cssSession = rootView.open('css.css') rootView.open('coffee.coffee') @@ -2065,7 +2063,17 @@ describe "Editor", -> expect(editor.getEditSessions().length).toBe 5 editor.setActiveEditSessionIndex(2) editor.destroyInactiveEditSessions() - expect(editor.getActiveEditSessionIndex()).toBe 1 + expect(editor.getActiveEditSessionIndex()).toBe 0 + expect(editor.getEditSessions().length).toBe 1 + expect(editor.getEditSessions()[0]).toBe cssSession + + it "prompts to save dirty buffers before destroying", -> + editor.setText("I'm dirty") + dirtySession = editor.activeEditSession + rootView.open('sample.txt') expect(editor.getEditSessions().length).toBe 2 - expect(editor.getEditSessions()[0]).toBe dirtySession - expect(editor.getEditSessions()[1]).toBe cssSession + spyOn(atom, "confirm") + editor.destroyInactiveEditSessions() + expect(atom.confirm).toHaveBeenCalled() + expect(editor.getEditSessions().length).toBe 2 + expect(editor.getEditSessions()[0].buffer.isModified()).toBeTruthy() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 3cbc9577f..e6864ad60 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -447,17 +447,18 @@ class Editor extends View destroyActiveEditSession: -> @destroyEditSessionIndex(@getActiveEditSessionIndex()) - destroyEditSessionIndex: (index) -> + destroyEditSessionIndex: (index, callback) -> return if @mini editSession = @editSessions[index] destroySession = => - if index is @getActiveEditSessionIndex() + if index is @getActiveEditSessionIndex() and @editSessions.length > 1 @loadPreviousEditSession() _.remove(@editSessions, editSession) editSession.destroy() @trigger 'editor:edit-session-removed', [editSession, index] @remove() if @editSessions.length is 0 + callback(index) if callback if editSession.buffer.isModified() @promptToSaveDirtySession(editSession, destroySession) @@ -465,13 +466,10 @@ class Editor extends View destroySession(editSession) destroyInactiveEditSessions: -> - index = 0 - while session = @editSessions[index] - if @activeEditSession is session or session.buffer.isModified() - index++ - else - @destroyEditSessionIndex(index) - + destroyIndex = (index) => + index++ if @activeEditSession is @editSessions[index] + @destroyEditSessionIndex(index, destroyIndex) if @editSessions[index] + destroyIndex(0) loadNextEditSession: -> nextIndex = (@getActiveEditSessionIndex() + 1) % @editSessions.length @setActiveEditSessionIndex(nextIndex) From 1535930521fa257f78fb014b01172893ce1fe1c5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 16:58:27 -0800 Subject: [PATCH 07/13] Show existing hidden window when re-opening Previously if Atom was opened to an already opened path but that window was hidden then a new window would be opened when instead the existing window should be unhidden. --- native/atom_application.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/atom_application.mm b/native/atom_application.mm index c2f2ed2ab..8eab6bfc5 100644 --- a/native/atom_application.mm +++ b/native/atom_application.mm @@ -139,7 +139,7 @@ - (void)open:(NSString *)path pidToKillWhenWindowCloses:(NSNumber *)pid { for (NSWindow *window in [self windows]) { - if ([window isVisible] && ![window isExcludedFromWindowsMenu]) { + if (![window isExcludedFromWindowsMenu]) { AtomWindowController *controller = [window windowController]; if ([path isEqualToString:controller.pathToOpen]) { [window makeKeyAndOrderFront:nil]; From 146ae9d776c7f3cbeba7930a8614ca672e97bc32 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 17:29:20 -0800 Subject: [PATCH 08/13] Refresh the Git index when the window gains focus Closes #121 --- native/v8_extensions/git.js | 2 ++ native/v8_extensions/git.mm | 21 ++++++++++++++------- src/app/git.coffee | 5 +++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/native/v8_extensions/git.js b/native/v8_extensions/git.js index a3f772682..1f32038d3 100644 --- a/native/v8_extensions/git.js +++ b/native/v8_extensions/git.js @@ -9,6 +9,7 @@ var $git = {}; native function checkoutHead(path); native function getDiffStats(path); native function isSubmodule(path); + native function refreshIndex(); function GitRepository(path) { var repo = getRepository(path); @@ -24,5 +25,6 @@ var $git = {}; GitRepository.prototype.checkoutHead = checkoutHead; GitRepository.prototype.getDiffStats = getDiffStats; GitRepository.prototype.isSubmodule = isSubmodule; + GitRepository.prototype.refreshIndex = refreshIndex; this.GitRepository = GitRepository; })(); diff --git a/native/v8_extensions/git.mm b/native/v8_extensions/git.mm index c68f23a49..095404d77 100644 --- a/native/v8_extensions/git.mm +++ b/native/v8_extensions/git.mm @@ -69,12 +69,6 @@ public: return CefV8Value::CreateInt(0); } - git_index* index; - if (git_repository_index(&index, repo) == GIT_OK) { - git_index_read(index); - git_index_free(index); - } - unsigned int status = 0; if (git_status_file(&status, repo, path) == GIT_OK) { return CefV8Value::CreateInt(status); @@ -192,7 +186,6 @@ public: BOOL isSubmodule = false; git_index* index; if (git_repository_index(&index, repo) == GIT_OK) { - git_index_read(index); const git_index_entry *entry = git_index_get_bypath(index, path, 0); isSubmodule = entry != NULL && (entry->mode & S_IFMT) == GIT_FILEMODE_COMMIT; git_index_free(index); @@ -201,6 +194,14 @@ public: return CefV8Value::CreateBool(isSubmodule); } + void RefreshIndex() { + git_index* index; + if (exists && git_repository_index(&index, repo) == GIT_OK) { + git_index_read(index); + git_index_free(index); + } + } + IMPLEMENT_REFCOUNTING(GitRepository); }; @@ -264,6 +265,12 @@ bool Git::Execute(const CefString& name, return true; } + if (name == "refreshIndex") { + GitRepository *userData = (GitRepository *)object->GetUserData().get(); + userData->RefreshIndex(); + return true; + } + return false; } diff --git a/src/app/git.coffee b/src/app/git.coffee index 44c69a135..4cab4bb2b 100644 --- a/src/app/git.coffee +++ b/src/app/git.coffee @@ -1,3 +1,5 @@ +$ = require 'jquery' + module.exports = class Git @@ -15,6 +17,9 @@ class Git constructor: (path) -> @repo = new GitRepository(path) + $(window).on 'focus', => @refreshIndex() + + refreshIndex: -> @repo.refreshIndex() getPath: -> @repo.getPath() From f5344080f15b373b7957022e2db14926bdcc6c72 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 17:35:54 -0800 Subject: [PATCH 09/13] Only compute Git status flags once Previously the status was fetched twice, once for if modified and once for if new. Now the flags are fetched once and Git now provides helpers to check the status flags directly for modified and new status. --- src/app/git.coffee | 14 ++++++++++---- src/packages/status-bar/src/status-bar.coffee | 7 +++++-- src/packages/tree-view/src/file-view.coffee | 10 ++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/app/git.coffee b/src/app/git.coffee index 4cab4bb2b..ea2dc1a0f 100644 --- a/src/app/git.coffee +++ b/src/app/git.coffee @@ -36,19 +36,25 @@ class Git isPathIgnored: (path) -> @repo.isIgnored(@relativize(path)) - isPathModified: (path) -> + isStatusModified: (status) -> modifiedFlags = @statusFlags.working_dir_modified | @statusFlags.working_dir_delete | @statusFlags.working_dir_typechange | @statusFlags.index_modified | @statusFlags.index_deleted | @statusFlags.index_typechange - (@getPathStatus(path) & modifiedFlags) > 0 + (status & modifiedFlags) > 0 - isPathNew: (path) -> + isPathModified: (path) -> + @isStatusModified(@getPathStatus(path)) + + isStatusNew: (status) -> newFlags = @statusFlags.working_dir_new | @statusFlags.index_new - (@getPathStatus(path) & newFlags) > 0 + (status & newFlags) > 0 + + isPathNew: (path) -> + @isStatusNew(@getPathStatus(path)) relativize: (path) -> workingDirectory = @getWorkingDirectory() diff --git a/src/packages/status-bar/src/status-bar.coffee b/src/packages/status-bar/src/status-bar.coffee index 841a0bce5..a43302b25 100644 --- a/src/packages/status-bar/src/status-bar.coffee +++ b/src/packages/status-bar/src/status-bar.coffee @@ -76,7 +76,10 @@ class StatusBar extends View @gitStatusIcon.addClass('git-status octicons') git = @buffer.getRepo() - if git?.isPathModified(path) + return unless git + + status = git.getPathStatus(path) + if git.isStatusModified(status) @gitStatusIcon.addClass('modified-status-icon') stats = git.getDiffStats(path) if stats.added and stats.deleted @@ -87,7 +90,7 @@ class StatusBar extends View @gitStatusIcon.text("-#{stats.deleted}") else @gitStatusIcon.text('') - else if git?.isPathNew(path) + else if git.isStatusNew(status) @gitStatusIcon.addClass('new-status-icon') @gitStatusIcon.text("+#{@buffer.getLineCount()}") diff --git a/src/packages/tree-view/src/file-view.coffee b/src/packages/tree-view/src/file-view.coffee index c0c7db492..ea75356da 100644 --- a/src/packages/tree-view/src/file-view.coffee +++ b/src/packages/tree-view/src/file-view.coffee @@ -36,10 +36,12 @@ class FileView extends View path = @getPath() if repo.isPathIgnored(path) @addClass('ignored') - else if repo.isPathModified(path) - @addClass('modified') - else if repo.isPathNew(path) - @addClass('new') + else + status = repo.getPathStatus(path) + if repo.isStatusModified(status) + @addClass('modified') + else if repo.isStatusNew(status) + @addClass('new') getPath: -> @file.path From f3b84ed33d5368ef83d216ba3d95dc521122efdc Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 18:13:08 -0800 Subject: [PATCH 10/13] Only show repo icon at root of tree --- src/packages/tree-view/src/directory-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/tree-view/src/directory-view.coffee b/src/packages/tree-view/src/directory-view.coffee index 55a2eb1ee..a44611a16 100644 --- a/src/packages/tree-view/src/directory-view.coffee +++ b/src/packages/tree-view/src/directory-view.coffee @@ -26,7 +26,7 @@ class DirectoryView extends View if repo? path = @directory.getPath() @directoryName.addClass('ignored') if repo.isPathIgnored(path) - if path is repo.getWorkingDirectory() + if not parent and path is repo.getWorkingDirectory() @directoryName.addClass('repository-icon') else if repo.isSubmodule(path) @directoryName.addClass('submodule-icon') From 438f510f8078a7bc63f972ba3f268b319ca25fd7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 18:14:27 -0800 Subject: [PATCH 11/13] Don't check if root is ignored --- src/packages/tree-view/src/directory-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/tree-view/src/directory-view.coffee b/src/packages/tree-view/src/directory-view.coffee index a44611a16..df177bba4 100644 --- a/src/packages/tree-view/src/directory-view.coffee +++ b/src/packages/tree-view/src/directory-view.coffee @@ -25,7 +25,7 @@ class DirectoryView extends View repo = @project.repo if repo? path = @directory.getPath() - @directoryName.addClass('ignored') if repo.isPathIgnored(path) + @directoryName.addClass('ignored') if parent and repo.isPathIgnored(path) if not parent and path is repo.getWorkingDirectory() @directoryName.addClass('repository-icon') else if repo.isSubmodule(path) From adfb6dee125fde6a7d06bd0b3030a289ba516697 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 18:21:03 -0800 Subject: [PATCH 12/13] :lipstick: --- src/packages/tree-view/src/directory-view.coffee | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/packages/tree-view/src/directory-view.coffee b/src/packages/tree-view/src/directory-view.coffee index df177bba4..3614f79da 100644 --- a/src/packages/tree-view/src/directory-view.coffee +++ b/src/packages/tree-view/src/directory-view.coffee @@ -23,17 +23,15 @@ class DirectoryView extends View @disclosureArrow.on 'click', => @toggleExpansion() repo = @project.repo + iconClass = 'directory-icon' if repo? path = @directory.getPath() - @directoryName.addClass('ignored') if parent and repo.isPathIgnored(path) - if not parent and path is repo.getWorkingDirectory() - @directoryName.addClass('repository-icon') - else if repo.isSubmodule(path) - @directoryName.addClass('submodule-icon') + if parent + @directoryName.addClass('ignored') if repo.isPathIgnored(path) + iconClass = 'submodule-icon' if repo.isSubmodule(path) else - @directoryName.addClass('directory-icon') - else - @directoryName.addClass('directory-icon') + iconClass = 'repository-icon' if path is repo.getWorkingDirectory() + @directoryName.addClass(iconClass) getPath: -> @directory.path From fffba45b50ce7cfc48e7a7b4a593a88341500ff9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Jan 2013 19:36:13 -0800 Subject: [PATCH 13/13] :lipstick: --- native/v8_extensions/git.mm | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/native/v8_extensions/git.mm b/native/v8_extensions/git.mm index 095404d77..8a334ed02 100644 --- a/native/v8_extensions/git.mm +++ b/native/v8_extensions/git.mm @@ -94,12 +94,7 @@ public: int result = git_checkout_head(repo, &options); free(copiedPath); - if (result == GIT_OK) { - return CefV8Value::CreateBool(true); - } - else { - return CefV8Value::CreateBool(false); - } + return CefV8Value::CreateBool(result == GIT_OK); } CefRefPtr GetDiffStats(const char *path) {