From 93a725d453be676c88cb66ea5adb5616751aadc3 Mon Sep 17 00:00:00 2001 From: Jim Graham Date: Wed, 25 Feb 2015 17:11:17 -0500 Subject: [PATCH 01/18] Remove dialog icon from updater atom/atom#5670 Remove the update icon on windows when showing the update modal dialog. Keep the icon for linux. This appears to be the only file outside of `build/` that uses the `'atom.png'` file. --- src/browser/auto-update-manager.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/browser/auto-update-manager.coffee b/src/browser/auto-update-manager.coffee index dfbdacfc4..25cf0dc18 100644 --- a/src/browser/auto-update-manager.coffee +++ b/src/browser/auto-update-manager.coffee @@ -17,10 +17,12 @@ class AutoUpdateManager constructor: (@version) -> @state = IdleState + @iconPath = path.resolve(__dirname, '..', '..', 'resources', 'atom.png'); if process.platform is 'win32' # Squirrel for Windows can't handle query params # https://github.com/Squirrel/Squirrel.Windows/issues/132 @feedUrl = 'https://atom.io/api/updates' + @iconPath = null; else @feedUrl = "https://atom.io/api/updates?version=#{@version}" @@ -89,7 +91,7 @@ class AutoUpdateManager dialog.showMessageBox type: 'info' buttons: ['OK'] - icon: path.resolve(__dirname, '..', '..', 'resources', 'atom.png') + icon: @iconPath message: 'No update available.' title: 'No Update Available' detail: "Version #{@version} is the latest version." @@ -100,7 +102,7 @@ class AutoUpdateManager dialog.showMessageBox type: 'warning' buttons: ['OK'] - icon: path.resolve(__dirname, '..', '..', 'resources', 'atom.png') + icon: @iconPath message: 'There was an error checking for updates.' title: 'Update Error' detail: message From b30702421832f3af76b58e4ae432fc2c9e3afa78 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 25 Feb 2015 16:49:30 -0800 Subject: [PATCH 02/18] Add API for getting paths relative to project dirs --- spec/project-spec.coffee | 17 +++++++++++++++++ src/project.coffee | 19 ++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/spec/project-spec.coffee b/spec/project-spec.coffee index 466431faf..31cf6c52f 100644 --- a/spec/project-spec.coffee +++ b/spec/project-spec.coffee @@ -438,6 +438,23 @@ describe "Project", -> randomPath = path.join("some", "random", "path") expect(atom.project.relativize(randomPath)).toBe randomPath + describe ".splitPath(path)", -> + it "returns the root path that contains the given path, and the path relativized to that root path", -> + atom.project.addPath(temp.mkdirSync("another-path")) + + rootPath = atom.project.getPaths()[0] + childPath = path.join(rootPath, "some", "child", "directory") + expect(atom.project.splitPath(childPath)).toEqual [rootPath, path.join("some", "child", "directory")] + + rootPath = atom.project.getPaths()[1] + childPath = path.join(rootPath, "some", "child", "directory") + expect(atom.project.splitPath(childPath)).toEqual [rootPath, path.join("some", "child", "directory")] + + describe "when the given path isn't inside of any of the project's path", -> + it "returns null for the root path, and the given path unchanged", -> + randomPath = path.join("some", "random", "path") + expect(atom.project.splitPath(randomPath)).toEqual [null, randomPath] + describe ".contains(path)", -> it "returns whether or not the given path is in one of the root directories", -> rootPath = atom.project.getPaths()[0] diff --git a/src/project.coffee b/src/project.coffee index d3fbd88eb..bb0006b1d 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -266,15 +266,28 @@ class Project extends Model else undefined - # Public: Make the given path relative to the project directory. + # Public: Make the given path relative to a project directory. # # * `fullPath` {String} full path relativize: (fullPath) -> + @splitPath(fullPath)[1] + + # Public: Get the path to the project directory that contains the given path, + # and the relative path from that project directory to the given path. + # + # * `fullPath` {String} An absolute path. + # + # Returns an {Array} with two elements: + # * `projectPath` The {String} path to the project directory that contains the + # given path, or `null` if none is found. + # * `relativePath` {String} The relative path from the project directory to + # the given path. + splitPath: (fullPath) -> return fullPath if fullPath?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme for rootDirectory in @rootDirectories relativePath = rootDirectory.relativize(fullPath) - return relativePath if relativePath isnt fullPath - fullPath + return [rootDirectory.getPath(), relativePath] unless relativePath is fullPath + [null, fullPath] # Public: Determines whether the given path (real or symbolic) is inside the # project's directory. From 03b5f559b60ea832ceb130bbc00b5fb7d1f77f5f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 26 Feb 2015 08:44:47 -0800 Subject: [PATCH 03/18] :arrow_up: language-perl@0.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c2e024a22..0e9983d1e 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "language-make": "0.13.0", "language-mustache": "0.11.0", "language-objective-c": "0.15.0", - "language-perl": "0.10.0", + "language-perl": "0.11.0", "language-php": "0.21.0", "language-property-list": "0.8.0", "language-python": "0.32.0", From 69b1a08ef5172ac5ab1750704c6f457ccec71a5d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 26 Feb 2015 08:46:00 -0800 Subject: [PATCH 04/18] Rename .splitPath -> .relativizePath --- spec/project-spec.coffee | 8 ++++---- src/project.coffee | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/project-spec.coffee b/spec/project-spec.coffee index 31cf6c52f..0d115f56f 100644 --- a/spec/project-spec.coffee +++ b/spec/project-spec.coffee @@ -438,22 +438,22 @@ describe "Project", -> randomPath = path.join("some", "random", "path") expect(atom.project.relativize(randomPath)).toBe randomPath - describe ".splitPath(path)", -> + describe ".relativizePath(path)", -> it "returns the root path that contains the given path, and the path relativized to that root path", -> atom.project.addPath(temp.mkdirSync("another-path")) rootPath = atom.project.getPaths()[0] childPath = path.join(rootPath, "some", "child", "directory") - expect(atom.project.splitPath(childPath)).toEqual [rootPath, path.join("some", "child", "directory")] + expect(atom.project.relativizePath(childPath)).toEqual [rootPath, path.join("some", "child", "directory")] rootPath = atom.project.getPaths()[1] childPath = path.join(rootPath, "some", "child", "directory") - expect(atom.project.splitPath(childPath)).toEqual [rootPath, path.join("some", "child", "directory")] + expect(atom.project.relativizePath(childPath)).toEqual [rootPath, path.join("some", "child", "directory")] describe "when the given path isn't inside of any of the project's path", -> it "returns null for the root path, and the given path unchanged", -> randomPath = path.join("some", "random", "path") - expect(atom.project.splitPath(randomPath)).toEqual [null, randomPath] + expect(atom.project.relativizePath(randomPath)).toEqual [null, randomPath] describe ".contains(path)", -> it "returns whether or not the given path is in one of the root directories", -> diff --git a/src/project.coffee b/src/project.coffee index bb0006b1d..9483d4228 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -270,7 +270,7 @@ class Project extends Model # # * `fullPath` {String} full path relativize: (fullPath) -> - @splitPath(fullPath)[1] + @relativizePath(fullPath)[1] # Public: Get the path to the project directory that contains the given path, # and the relative path from that project directory to the given path. @@ -282,7 +282,7 @@ class Project extends Model # given path, or `null` if none is found. # * `relativePath` {String} The relative path from the project directory to # the given path. - splitPath: (fullPath) -> + relativizePath: (fullPath) -> return fullPath if fullPath?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme for rootDirectory in @rootDirectories relativePath = rootDirectory.relativize(fullPath) From 5f2a92f4862022259ec33e023d7869c3412512d0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 26 Feb 2015 08:46:14 -0800 Subject: [PATCH 05/18] Remove public docs for Project::relativize --- src/project.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/project.coffee b/src/project.coffee index 9483d4228..c92462ead 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -266,9 +266,6 @@ class Project extends Model else undefined - # Public: Make the given path relative to a project directory. - # - # * `fullPath` {String} full path relativize: (fullPath) -> @relativizePath(fullPath)[1] From 9927679941b6c9b415174983b89a952ecac9d8f4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 26 Feb 2015 08:47:31 -0800 Subject: [PATCH 06/18] :arrow_up: symbols-view@0.85 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e9983d1e..7016f47bc 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "spell-check": "0.55.0", "status-bar": "0.60.0", "styleguide": "0.44.0", - "symbols-view": "0.84.0", + "symbols-view": "0.85.0", "tabs": "0.67.0", "timecop": "0.31.0", "tree-view": "0.162.0", From 59f08ab33b8b838517924e680097ce562b355ef8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 26 Feb 2015 09:05:53 -0800 Subject: [PATCH 07/18] :arrow_up: tree-view --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7016f47bc..4e3ce32b0 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "symbols-view": "0.85.0", "tabs": "0.67.0", "timecop": "0.31.0", - "tree-view": "0.162.0", + "tree-view": "0.163.0", "update-package-dependencies": "0.8.0", "welcome": "0.24.0", "whitespace": "0.29.0", From 3b79ecbc8a347b1c2e3f5af16e56d389e88989d4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 26 Feb 2015 09:07:30 -0800 Subject: [PATCH 08/18] Only set iconPath ivar on Windows --- src/browser/auto-update-manager.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/browser/auto-update-manager.coffee b/src/browser/auto-update-manager.coffee index 25cf0dc18..a0c1f2da8 100644 --- a/src/browser/auto-update-manager.coffee +++ b/src/browser/auto-update-manager.coffee @@ -17,13 +17,12 @@ class AutoUpdateManager constructor: (@version) -> @state = IdleState - @iconPath = path.resolve(__dirname, '..', '..', 'resources', 'atom.png'); if process.platform is 'win32' # Squirrel for Windows can't handle query params # https://github.com/Squirrel/Squirrel.Windows/issues/132 @feedUrl = 'https://atom.io/api/updates' - @iconPath = null; else + @iconPath = path.resolve(__dirname, '..', '..', 'resources', 'atom.png') @feedUrl = "https://atom.io/api/updates?version=#{@version}" process.nextTick => @setupAutoUpdater() From 173502bab4340150ce5e57e8515ecaed17fc4c1f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 26 Feb 2015 10:46:39 -0800 Subject: [PATCH 09/18] Base state path on project paths --- spec/atom-spec.coffee | 28 ++++++++++++++++++++++++++++ src/atom.coffee | 11 +++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 2c1a40afc..aa777b134 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -3,6 +3,8 @@ Exec = require('child_process').exec path = require 'path' Package = require '../src/package' ThemeManager = require '../src/theme-manager' +_ = require "underscore-plus" +temp = require "temp" describe "the `atom` global", -> describe 'window sizing methods', -> @@ -124,3 +126,29 @@ describe "the `atom` global", -> line: 2 column: 3 originalError: error + + describe "saving and loading", -> + afterEach -> atom.mode = "spec" + + it "selects the state based on the current project paths", -> + Atom = atom.constructor + [dir1, dir2] = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")] + + loadSettings = _.extend Atom.getLoadSettings(), + initialPaths: [dir1] + windowState: null + + spyOn(Atom, 'getLoadSettings').andCallFake -> loadSettings + spyOn(Atom, 'getStorageDirPath').andReturn(temp.mkdirSync("storage-dir-")) + + atom.mode = "editor" + atom.state.stuff = "cool" + atom.project.setPaths([dir1, dir2]) + atom.saveSync.originalValue.call(atom) + + atom1 = Atom.loadOrCreate("editor") + expect(atom1.state.stuff).toBeUndefined() + + loadSettings.initialPaths = [dir1, dir2] + atom2 = Atom.loadOrCreate("editor") + expect(atom2.state.stuff).toBe("cool") diff --git a/src/atom.coffee b/src/atom.coffee index 385180dfd..8ad4780c9 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -73,7 +73,7 @@ class Atom extends Model # Loads and returns the serialized state corresponding to this window # if it exists; otherwise returns undefined. @loadState: (mode) -> - statePath = @getStatePath(mode) + statePath = @getStatePath(@getLoadSettings().initialPaths, mode) if fs.existsSync(statePath) try @@ -90,14 +90,13 @@ class Atom extends Model # Returns the path where the state for the current window will be # located if it exists. - @getStatePath: (mode) -> + @getStatePath: (paths, mode) -> switch mode when 'spec' filename = 'spec' when 'editor' - {initialPaths} = @getLoadSettings() - if initialPaths?.length > 0 - sha1 = crypto.createHash('sha1').update(initialPaths.join("\n")).digest('hex') + if paths?.length > 0 + sha1 = crypto.createHash('sha1').update(paths.join("\n")).digest('hex') filename = "editor-#{sha1}" if filename @@ -773,7 +772,7 @@ class Atom extends Model saveSync: -> stateString = JSON.stringify(@state) - if statePath = @constructor.getStatePath(@mode) + if statePath = @constructor.getStatePath(@project?.getPaths(), @mode) fs.writeFileSync(statePath, stateString, 'utf8') else @getCurrentWindow().loadSettings.windowState = stateString From 1f80b9c5d39e667815cdb26c17a2b6216073f4bb Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 26 Feb 2015 11:45:33 -0800 Subject: [PATCH 10/18] :arrow_up: notifications@0.29.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e3ce32b0..b87128ff3 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "link": "0.30.0", "markdown-preview": "0.137.0", "metrics": "0.45.0", - "notifications": "0.28.0", + "notifications": "0.29.0", "open-on-github": "0.32.0", "package-generator": "0.38.0", "release-notes": "0.51.0", From fdda26a0a37cda6b1afe20a382f930c4eebb8f6f Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 26 Feb 2015 12:15:12 -0800 Subject: [PATCH 11/18] :arrow_up: notifications@0.30.0 Fix specs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b87128ff3..f31f7ac5b 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "link": "0.30.0", "markdown-preview": "0.137.0", "metrics": "0.45.0", - "notifications": "0.29.0", + "notifications": "0.30.0", "open-on-github": "0.32.0", "package-generator": "0.38.0", "release-notes": "0.51.0", From ddcb874f6bcd9b15252d353d24475f1d622b474b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 26 Feb 2015 12:50:56 -0800 Subject: [PATCH 12/18] Base state file path on sorted project paths --- spec/atom-spec.coffee | 2 +- src/atom.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index aa777b134..12d094428 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -149,6 +149,6 @@ describe "the `atom` global", -> atom1 = Atom.loadOrCreate("editor") expect(atom1.state.stuff).toBeUndefined() - loadSettings.initialPaths = [dir1, dir2] + loadSettings.initialPaths = [dir2, dir1] atom2 = Atom.loadOrCreate("editor") expect(atom2.state.stuff).toBe("cool") diff --git a/src/atom.coffee b/src/atom.coffee index 8ad4780c9..303b0cfe7 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -96,7 +96,7 @@ class Atom extends Model filename = 'spec' when 'editor' if paths?.length > 0 - sha1 = crypto.createHash('sha1').update(paths.join("\n")).digest('hex') + sha1 = crypto.createHash('sha1').update(paths.slice().sort().join("\n")).digest('hex') filename = "editor-#{sha1}" if filename From 84c434f86c4a9f325f202769696e859f3c6d9af3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 26 Feb 2015 13:50:50 -0800 Subject: [PATCH 13/18] :arrow_up: open-on-github --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f31f7ac5b..e1e049c2e 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "markdown-preview": "0.137.0", "metrics": "0.45.0", "notifications": "0.30.0", - "open-on-github": "0.32.0", + "open-on-github": "0.33.0", "package-generator": "0.38.0", "release-notes": "0.51.0", "settings-view": "0.183.0", From cd310dbe58b8e45e0b4f954df13b701b9439949e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 26 Feb 2015 14:50:59 -0700 Subject: [PATCH 14/18] =?UTF-8?q?Rename=20=E2=80=98blinkCursorsOff?= =?UTF-8?q?=E2=80=99=20to=20=E2=80=98cursorsVisible=E2=80=99=20in=20presen?= =?UTF-8?q?ter=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/text-editor-presenter-spec.coffee | 26 +++++++++++++------------- src/cursors-component.coffee | 10 +++++----- src/text-editor-presenter.coffee | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 163521c32..0d526b5f2 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -1135,49 +1135,49 @@ describe "TextEditorPresenter", -> presenter = buildPresenter(explicitHeight: 20, scrollTop: 0) expect(stateForCursor(presenter, 0).width).toBe 10 - describe ".blinkCursorsOff", -> + describe ".cursorsVisible", -> it "alternates between true and false twice per ::cursorBlinkPeriod", -> cursorBlinkPeriod = 100 cursorBlinkResumeDelay = 200 presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay}) - expect(presenter.state.content.blinkCursorsOff).toBe false + expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe true + expect(presenter.state.content.cursorsVisible).toBe false expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe false + expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe true + expect(presenter.state.content.cursorsVisible).toBe false it "stops alternating for ::cursorBlinkResumeDelay when a cursor moves or a cursor is added", -> cursorBlinkPeriod = 100 cursorBlinkResumeDelay = 200 presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay}) - expect(presenter.state.content.blinkCursorsOff).toBe false + expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe true + expect(presenter.state.content.cursorsVisible).toBe false expectStateUpdate presenter, -> editor.moveRight() - expect(presenter.state.content.blinkCursorsOff).toBe false + expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkResumeDelay) advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe true + expect(presenter.state.content.cursorsVisible).toBe false expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe false + expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe true + expect(presenter.state.content.cursorsVisible).toBe false expectStateUpdate presenter, -> editor.addCursorAtBufferPosition([1, 0]) - expect(presenter.state.content.blinkCursorsOff).toBe false + expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkResumeDelay) advanceClock(cursorBlinkPeriod / 2) - expect(presenter.state.content.blinkCursorsOff).toBe true + expect(presenter.state.content.cursorsVisible).toBe false describe ".highlights", -> stateForHighlight = (presenter, decoration) -> diff --git a/src/cursors-component.coffee b/src/cursors-component.coffee index e11019d6c..ae844bfe0 100644 --- a/src/cursors-component.coffee +++ b/src/cursors-component.coffee @@ -13,12 +13,12 @@ class CursorsComponent @oldState ?= {cursors: {}} # update blink class - if newState.blinkCursorsOff isnt @oldState.blinkCursorsOff - if newState.blinkCursorsOff - @domNode.classList.add 'blink-off' - else + if newState.cursorsVisible isnt @oldState.cursorsVisible + if newState.cursorsVisible @domNode.classList.remove 'blink-off' - @oldState.blinkCursorsOff = newState.blinkCursorsOff + else + @domNode.classList.add 'blink-off' + @oldState.cursorsVisible = newState.cursorsVisible # remove cursors for id of @oldState.cursors diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 955b63cc4..20f575407 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -113,7 +113,7 @@ class TextEditorPresenter hiddenInput: {} content: scrollingVertically: false - blinkCursorsOff: false + cursorsVisible: true lines: {} highlights: {} overlays: {} @@ -983,11 +983,11 @@ class TextEditorPresenter clearInterval(@toggleCursorBlinkHandle) toggleCursorBlink: -> - @state.content.blinkCursorsOff = not @state.content.blinkCursorsOff + @state.content.cursorsVisible = not @state.content.cursorsVisible @emitter.emit 'did-update-state' pauseCursorBlinking: -> - @state.content.blinkCursorsOff = false + @state.content.cursorsVisible = true @stopBlinkingCursors() @startBlinkingCursorsAfterDelay ?= _.debounce(@startBlinkingCursors, @getCursorBlinkResumeDelay()) @startBlinkingCursorsAfterDelay() From 6a9abd1f6664cd81e1d8fcfb6032578bcdead89c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 26 Feb 2015 15:23:11 -0700 Subject: [PATCH 15/18] =?UTF-8?q?:racehorse:=20Don=E2=80=99t=20blink=20cur?= =?UTF-8?q?sors=20when=20editor=20isn=E2=80=99t=20focused?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Max Brunsfeld --- spec/text-editor-component-spec.coffee | 5 +++-- spec/text-editor-presenter-spec.coffee | 20 +++++++++++++++++--- src/text-editor-presenter.coffee | 22 +++++++++++++++------- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index d7b9ed2ff..a830efe04 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -794,6 +794,8 @@ describe "TextEditorComponent", -> it "blinks cursors when they aren't moving", -> cursorsNode = componentNode.querySelector('.cursors') + wrapperNode.focus() + nextAnimationFrame() expect(cursorsNode.classList.contains('blink-off')).toBe false advanceClock(component.cursorBlinkPeriod / 2) @@ -2481,8 +2483,7 @@ describe "TextEditorComponent", -> gutterWidth = componentNode.querySelector('.gutter').offsetWidth componentNode.style.width = gutterWidth + 14 * charWidth + editor.getVerticalScrollbarWidth() + 'px' advanceClock(atom.views.documentPollingInterval) - nextAnimationFrame() # won't poll until cursor blinks - nextAnimationFrame() # handle update requested by poll + nextAnimationFrame() expect(componentNode.querySelector('.line').textContent).toBe "var quicksort " it "accounts for the scroll view's padding when determining the wrap location", -> diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 0d526b5f2..2ee966630 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -1136,10 +1136,10 @@ describe "TextEditorPresenter", -> expect(stateForCursor(presenter, 0).width).toBe 10 describe ".cursorsVisible", -> - it "alternates between true and false twice per ::cursorBlinkPeriod", -> + it "alternates between true and false twice per ::cursorBlinkPeriod when the editor is focused", -> cursorBlinkPeriod = 100 cursorBlinkResumeDelay = 200 - presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay}) + presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay, focused: true}) expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) @@ -1148,11 +1148,25 @@ describe "TextEditorPresenter", -> expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) expect(presenter.state.content.cursorsVisible).toBe false + expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) + expect(presenter.state.content.cursorsVisible).toBe true + + expectStateUpdate presenter, -> presenter.setFocused(false) + expect(presenter.state.content.cursorsVisible).toBe false + advanceClock(cursorBlinkPeriod / 2) + expect(presenter.state.content.cursorsVisible).toBe false + advanceClock(cursorBlinkPeriod / 2) + expect(presenter.state.content.cursorsVisible).toBe false + + expectStateUpdate presenter, -> presenter.setFocused(true) + expect(presenter.state.content.cursorsVisible).toBe true + expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) + expect(presenter.state.content.cursorsVisible).toBe false it "stops alternating for ::cursorBlinkResumeDelay when a cursor moves or a cursor is added", -> cursorBlinkPeriod = 100 cursorBlinkResumeDelay = 200 - presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay}) + presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay, focused: true}) expect(presenter.state.content.cursorsVisible).toBe true expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 20f575407..5690f51c9 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -25,7 +25,7 @@ class TextEditorPresenter @observeModel() @observeConfig() @buildState() - @startBlinkingCursors() + @startBlinkingCursors() if @focused destroy: -> @disposables.dispose() @@ -113,7 +113,7 @@ class TextEditorPresenter hiddenInput: {} content: scrollingVertically: false - cursorsVisible: true + cursorsVisible: false lines: {} highlights: {} overlays: {} @@ -507,6 +507,10 @@ class TextEditorPresenter setFocused: (focused) -> unless @focused is focused @focused = focused + if @focused + @startBlinkingCursors() + else + @stopBlinkingCursors(false) @updateFocusedState() @updateHiddenInputState() @@ -977,18 +981,22 @@ class TextEditorPresenter @updateCursorState(cursor) startBlinkingCursors: -> - @toggleCursorBlinkHandle = setInterval(@toggleCursorBlink.bind(this), @getCursorBlinkPeriod() / 2) + unless @toggleCursorBlinkHandle + @state.content.cursorsVisible = true + @toggleCursorBlinkHandle = setInterval(@toggleCursorBlink.bind(this), @getCursorBlinkPeriod() / 2) - stopBlinkingCursors: -> - clearInterval(@toggleCursorBlinkHandle) + stopBlinkingCursors: (visible) -> + if @toggleCursorBlinkHandle + @state.content.cursorsVisible = visible + clearInterval(@toggleCursorBlinkHandle) + @toggleCursorBlinkHandle = null toggleCursorBlink: -> @state.content.cursorsVisible = not @state.content.cursorsVisible @emitter.emit 'did-update-state' pauseCursorBlinking: -> - @state.content.cursorsVisible = true - @stopBlinkingCursors() + @stopBlinkingCursors(true) @startBlinkingCursorsAfterDelay ?= _.debounce(@startBlinkingCursors, @getCursorBlinkResumeDelay()) @startBlinkingCursorsAfterDelay() @emitter.emit 'did-update-state' From 30e3813a71c6211f204de8fb1d8c61fd88f7dc44 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 26 Feb 2015 15:02:36 -0800 Subject: [PATCH 16/18] :arrow_up: snippets@0.77 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e1e049c2e..02eeaff38 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "package-generator": "0.38.0", "release-notes": "0.51.0", "settings-view": "0.183.0", - "snippets": "0.76.0", + "snippets": "0.77.0", "spell-check": "0.55.0", "status-bar": "0.60.0", "styleguide": "0.44.0", From efefc0dc66b96cfddaa8f60d150d11ecc8321a87 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 27 Feb 2015 00:55:03 +0100 Subject: [PATCH 17/18] `DisplayBuffer#getEditorWidthInChars` must always be >= 0 --- spec/display-buffer-spec.coffee | 8 ++++++++ src/display-buffer.coffee | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index 514a51625..23b658c04 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -80,6 +80,14 @@ describe "DisplayBuffer", -> atom.config.set('editor.softWrapAtPreferredLineLength', false) expect(displayBuffer.tokenizedLineForScreenRow(10).text).toBe ' return ' + describe "when editor width is negative", -> + it "does not hang while wrapping", -> + displayBuffer.setDefaultCharWidth(1) + displayBuffer.setWidth(-1) + + expect(displayBuffer.tokenizedLineForScreenRow(1).text).toBe " " + expect(displayBuffer.tokenizedLineForScreenRow(2).text).toBe " var sort = function(items) {" + describe "when the line is shorter than the max line length", -> it "renders the line unchanged", -> expect(displayBuffer.tokenizedLineForScreenRow(0).text).toBe buffer.lineForRow(0) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 79eff09cd..e09f1580c 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -458,7 +458,7 @@ class DisplayBuffer extends Model width = @width ? @getScrollWidth() width -= @getVerticalScrollbarWidth() if width? and @defaultCharWidth > 0 - Math.floor(width / @defaultCharWidth) + Math.max(0, Math.floor(width / @defaultCharWidth)) else @editorWidthInChars From 2e7c56d6eef8def6aa387af7451b3a683b7b25cc Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 26 Feb 2015 17:21:50 -0800 Subject: [PATCH 18/18] :arrow_up: notifications@0.31 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 02eeaff38..1a50c58b0 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "link": "0.30.0", "markdown-preview": "0.137.0", "metrics": "0.45.0", - "notifications": "0.30.0", + "notifications": "0.31.0", "open-on-github": "0.33.0", "package-generator": "0.38.0", "release-notes": "0.51.0",