Comparar commits

...

20 Commits

Autor SHA1 Mensagem Data
Nathan Sobo c8b92526ec Group editor.increase/decreaseIndentPattern settings under editor.indent
Since these settings are paired, we don’t want to retrieve settings
from two different scopes for a given usage. This also emits a
deprecation warning when the old settings are used.
2014-12-11 10:49:20 -07:00
Nathan Sobo 92a9c7aef6 Move editor.commentStart/End properties to editor.comment.start/end
And emit a deprecation warning
2014-12-11 10:36:47 -07:00
Nathan Sobo d51a86e804 ⬆️ markdown-preview for deprecation fixes 2014-12-11 09:03:31 -07:00
Ben Ogle 278a507653 Merge pull request #4531 from atom/bo-buffered-process-error
Better BufferedProcess error handling
2014-12-10 18:17:09 -08:00
Nathan Sobo 7422f4378e Add property filters to TextEditor::getDecorations methods
This makes it much easier to write tests that inspect the state of
decorations.
2014-12-10 19:11:50 -07:00
Ben Ogle f2ab14656b BufferedProcess::onDidThrowError -> ::onDidThrowError 2014-12-10 18:08:43 -08:00
Ben Ogle 453abf8b90 Update solarized-dark-syntax to fix ruby 2014-12-10 17:54:01 -08:00
Ben Ogle 7866f0819d Upgrade keybinding-resolver to fix the inability to unhide 2014-12-10 17:53:40 -08:00
Kevin Sawicki 921e3c581d ⬆️ keybinding-resolver@0.22 2014-12-10 17:29:17 -08:00
Max Brunsfeld 58aa87438d ⬆️ snippets@0.58.0
For deprecation fixes
2014-12-10 16:45:14 -08:00
Ben Ogle ad73902382 📝 Add docs 2014-12-10 16:27:05 -08:00
Ben Ogle bf63a9715c Add BufferedProcess::onDidThrowError() 2014-12-10 16:26:57 -08:00
Kevin Sawicki 06c52c6873 ⬆️ language-javascript@0.48 2014-12-10 16:21:33 -08:00
Kevin Sawicki 9ac27bc2f8 Grim.logDeprecationWarnings -> Grim.logDeprecations
Closes #4486
2014-12-10 16:05:36 -08:00
Ben Ogle 98caaf0d70 :up_arrow: fuzzy-finder@0.62.0 2014-12-10 15:30:29 -08:00
Ben Ogle a102d1e134 Upgrade styleguide to fix build 2014-12-10 15:14:36 -08:00
Ben Ogle 6caa86fb04 Upgrade styleguide to include colors 2014-12-10 14:54:12 -08:00
Max Brunsfeld b1e0c8132d ⬆️ tree-view@0.137.0 2014-12-10 14:39:05 -08:00
Kevin Sawicki f3947dd6e0 ⬆️ find-and-replace@0.152 2014-12-10 14:06:18 -08:00
Kevin Sawicki 27dbbabe09 Prepare 0.157 2014-12-10 13:34:06 -08:00
12 arquivos alterados com 235 adições e 57 exclusões
+10 -10
Ver Arquivo
@@ -1,7 +1,7 @@
{
"name": "atom",
"productName": "Atom",
"version": "0.156.0",
"version": "0.157.0",
"description": "A hackable text editor for the 21st Century.",
"main": "./src/browser/main.js",
"repository": {
@@ -73,7 +73,7 @@
"atom-light-ui": "0.36.0",
"base16-tomorrow-dark-theme": "0.22.0",
"base16-tomorrow-light-theme": "0.5.0",
"solarized-dark-syntax": "0.25.0",
"solarized-dark-syntax": "0.26.0",
"solarized-light-syntax": "0.13.0",
"archive-view": "0.40.0",
"autocomplete": "0.34.0",
@@ -87,30 +87,30 @@
"dev-live-reload": "0.35.0",
"encoding-selector": "0.10.0",
"exception-reporting": "0.21.0",
"find-and-replace": "0.151.0",
"fuzzy-finder": "0.61.0",
"find-and-replace": "0.152.0",
"fuzzy-finder": "0.62.0",
"git-diff": "0.45.0",
"go-to-line": "0.27.0",
"grammar-selector": "0.37.0",
"image-view": "0.43.0",
"incompatible-packages": "0.15.0",
"keybinding-resolver": "0.21.0",
"keybinding-resolver": "0.23.0",
"link": "0.28.0",
"markdown-preview": "0.111.0",
"markdown-preview": "0.112.0",
"metrics": "0.39.0",
"notifications": "0.13.0",
"open-on-github": "0.31.0",
"package-generator": "0.33.0",
"release-notes": "0.36.0",
"settings-view": "0.161.0",
"snippets": "0.57.0",
"snippets": "0.58.0",
"spell-check": "0.44.0",
"status-bar": "0.53.0",
"styleguide": "0.32.0",
"styleguide": "0.34.0",
"symbols-view": "0.70.0",
"tabs": "0.57.0",
"timecop": "0.24.0",
"tree-view": "0.136.0",
"tree-view": "0.137.0",
"update-package-dependencies": "0.7.0",
"welcome": "0.21.0",
"whitespace": "0.27.0",
@@ -125,7 +125,7 @@
"language-html": "0.26.1",
"language-hyperlink": "0.12.2",
"language-java": "0.13.0",
"language-javascript": "0.47.0",
"language-javascript": "0.48.0",
"language-json": "0.10.0",
"language-less": "0.21.0",
"language-make": "0.12.0",
+42
Ver Arquivo
@@ -0,0 +1,42 @@
BufferedProcess = require '../src/buffered-process'
describe "BufferedProcess", ->
describe "when a bad command is specified", ->
[oldOnError] = []
beforeEach ->
oldOnError = window.onerror
window.onerror = jasmine.createSpy()
afterEach ->
window.onerror = oldOnError
describe "when there is an error handler specified", ->
it "calls the error handler and does not throw an exception", ->
process = new BufferedProcess
command: 'bad-command-nope'
args: ['nothing']
options: {}
errorSpy = jasmine.createSpy().andCallFake (error) -> error.handle()
process.onWillThrowError(errorSpy)
waitsFor -> errorSpy.callCount > 0
runs ->
expect(window.onerror).not.toHaveBeenCalled()
expect(errorSpy).toHaveBeenCalled()
expect(errorSpy.mostRecentCall.args[0].error.message).toContain 'spawn bad-command-nope ENOENT'
describe "when there is not an error handler specified", ->
it "calls the error handler and does not throw an exception", ->
process = new BufferedProcess
command: 'bad-command-nope'
args: ['nothing']
options: {}
waitsFor -> window.onerror.callCount > 0
runs ->
expect(window.onerror).toHaveBeenCalled()
expect(window.onerror.mostRecentCall.args[0]).toContain 'Failed to spawn command `bad-command-nope`'
expect(window.onerror.mostRecentCall.args[4].name).toBe 'BufferedProcessError'
+6
Ver Arquivo
@@ -1085,6 +1085,12 @@ describe "DisplayBuffer", ->
expect(oldProperties).toEqual decorationProperties
expect(newProperties).toEqual type: 'gutter', class: 'two', id: decoration.id
describe "::getDecorations(properties)", ->
it "returns decorations matching the given optional properties", ->
expect(displayBuffer.getDecorations()).toEqual [decoration]
expect(displayBuffer.getDecorations(class: 'two').length).toEqual 0
expect(displayBuffer.getDecorations(class: 'one').length).toEqual 1
describe "::setScrollTop", ->
beforeEach ->
displayBuffer.manageScrollPosition = true
@@ -1,3 +1,6 @@
'.source.omg':
'editor':
'increaseIndentPattern': '^a'
'decreaseIndentPattern': '^z'
'commentStart': '/*'
'commentEnd': '*/'
+30 -4
Ver Arquivo
@@ -1,3 +1,4 @@
Grim = require 'grim'
{$, $$} = require '../src/space-pen-extensions'
Package = require '../src/package'
@@ -5,6 +6,7 @@ describe "PackageManager", ->
workspaceElement = null
beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
spyOn(Grim, 'deprecate') # suppress deprecation warnings due to comment strings
describe "::loadPackage(name)", ->
it "continues if the package has an invalid package.json", ->
@@ -367,7 +369,31 @@ describe "PackageManager", ->
atom.packages.activatePackage("package-with-scoped-properties")
runs ->
expect(atom.config.get ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a'
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBe '^a'
it "combines 'editor.commentStart' and 'editor.commentEnd' strings under the 'editor.comment' key path", ->
if atom.packages.isPackageLoaded("package-with-scoped-properties")
atom.packages.unloadPackage("package-with-scoped-properties")
waitsForPromise ->
atom.packages.activatePackage("package-with-scoped-properties")
runs ->
expect(atom.config.get ['.source.omg'], 'editor.comment.start').toBe '/*'
expect(atom.config.get ['.source.omg'], 'editor.comment.end').toBe '*/'
expect(Grim.deprecate).toHaveBeenCalled()
it "combines 'editor.increaseIndentPattern' and 'editor.decreaseIndentPattern' strings under the 'editor.indent' key path", ->
if atom.packages.isPackageLoaded("package-with-scoped-properties")
atom.packages.unloadPackage("package-with-scoped-properties")
waitsForPromise ->
atom.packages.activatePackage("package-with-scoped-properties")
runs ->
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBe '^a'
expect(atom.config.get ['.source.omg'], 'editor.indent.decreasePattern').toBe '^z'
expect(Grim.deprecate).toHaveBeenCalled()
describe "converted textmate packages", ->
it "loads the package's grammars", ->
@@ -386,7 +412,7 @@ describe "PackageManager", ->
atom.packages.activatePackage('language-ruby')
runs ->
expect(atom.config.get(['.source.ruby'], 'editor.commentStart')).toBe '# '
expect(atom.config.get(['.source.ruby'], 'editor.comment.start')).toBe '# '
describe "::deactivatePackage(id)", ->
afterEach ->
@@ -493,9 +519,9 @@ describe "PackageManager", ->
atom.packages.activatePackage("package-with-scoped-properties")
runs ->
expect(atom.config.get ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a'
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBe '^a'
atom.packages.deactivatePackage("package-with-scoped-properties")
expect(atom.config.get ['.source.omg'], 'editor.increaseIndentPattern').toBeUndefined()
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBeUndefined()
describe "textmate packages", ->
it "removes the package's grammars", ->
+41
Ver Arquivo
@@ -1,5 +1,6 @@
_ = require 'underscore-plus'
ChildProcess = require 'child_process'
{Emitter} = require 'event-kit'
# Extended: A wrapper which provides standard error/output line buffering for
# Node's ChildProcess.
@@ -17,6 +18,10 @@ ChildProcess = require 'child_process'
# ```
module.exports =
class BufferedProcess
###
Section: Construction
###
# Public: Runs the given command by spawning a new child process.
#
# * `options` An {Object} with the following keys:
@@ -39,6 +44,7 @@ class BufferedProcess
# * `exit` The callback {Function} which receives a single argument
# containing the exit status (optional).
constructor: ({command, args, options, stdout, stderr, exit}={}) ->
@emitter = new Emitter
options ?= {}
# Related to joyent/node#2318
if process.platform is "win32"
@@ -94,6 +100,41 @@ class BufferedProcess
processExited = true
triggerExitCallback()
@process.on 'error', (error) =>
handled = false
handle = -> handled = true
@emitter.emit 'will-throw-error', {error, handle}
if error.code is 'ENOENT' and error.syscall.indexOf('spawn') is 0
error = new Error("Failed to spawn command `#{command}`. Make sure `#{command}` is installed and on your PATH", error.path)
error.name = 'BufferedProcessError'
throw error unless handled
###
Section: Event Subscription
###
# Public: Will call your callback when an error will be raised by the process.
# Usually this is due to the command not being available or not on the PATH.
# You can call `handle()` on the object passed to your callback to indicate
# that you have handled this error.
#
# * `callback` {Function} callback
# * `errorObject` {Object}
# * `error` {Object} the error object
# * `handle` {Function} call this to indicate you have handled the error.
# The error will not be thrown if this function is called.
#
# Returns a {Disposable}
onWillThrowError: (callback) ->
@emitter.on 'will-throw-error', callback
###
Section: Helper Methods
###
# Helper method to pass data line by line.
#
# * `stream` The Stream to read from.
+14 -8
Ver Arquivo
@@ -81,14 +81,20 @@ module.exports =
type: 'object'
properties:
# These settings are used in scoped fashion only. No defaults.
commentStart:
type: ['string', 'null']
commentEnd:
type: ['string', 'null']
increaseIndentPattern:
type: ['string', 'null']
decreaseIndentPattern:
type: ['string', 'null']
comment:
type: 'object'
properties:
start:
type: ['string', 'null']
end:
type: ['string', 'null']
indent:
type: 'object'
properties:
increasePattern:
type: ['string', 'null']
decreasePattern:
type: ['string', 'null']
foldEndPattern:
type: ['string', 'null']
+14 -9
Ver Arquivo
@@ -883,23 +883,28 @@ class DisplayBuffer extends Model
decorationForId: (id) ->
@decorationsById[id]
getDecorations: ->
getDecorations: (propertyFilter) ->
allDecorations = []
for markerId, decorations of @decorationsByMarkerId
allDecorations = allDecorations.concat(decorations) if decorations?
if propertyFilter?
allDecorations = allDecorations.filter (decoration) ->
for key, value of propertyFilter
return false unless decoration.properties[key] is value
true
allDecorations
getLineDecorations: ->
@getDecorations().filter (decoration) -> decoration.isType('line')
getLineDecorations: (propertyFilter) ->
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('line')
getGutterDecorations: ->
@getDecorations().filter (decoration) -> decoration.isType('gutter')
getGutterDecorations: (propertyFilter) ->
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('gutter')
getHighlightDecorations: ->
@getDecorations().filter (decoration) -> decoration.isType('highlight')
getHighlightDecorations: (propertyFilter) ->
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('highlight')
getOverlayDecorations: ->
@getDecorations().filter (decoration) -> decoration.isType('overlay')
getOverlayDecorations: (propertyFilter) ->
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('overlay')
decorationsForScreenRowRange: (startScreenRow, endScreenRow) ->
decorationsByMarkerId = {}
+23 -15
Ver Arquivo
@@ -30,13 +30,15 @@ class LanguageMode
# Returns an {Array} of the commented {Ranges}.
toggleLineCommentsForBufferRows: (start, end) ->
scopeDescriptor = @editor.scopeDescriptorForBufferPosition([start, 0])
properties = atom.config.settingsForScopeDescriptor(scopeDescriptor, 'editor.commentStart')[0]
return unless properties
commentStartString = _.valueForKeyPath(properties, 'editor.commentStart')
commentEndString = _.valueForKeyPath(properties, 'editor.commentEnd')
commentStrings = atom.config.get(scopeDescriptor, 'editor.comment')
return unless commentStartString
return unless commentStrings?
commentStartString = commentStrings.start
commentEndString = commentStrings.end
return unless commentStartString?
buffer = @editor.buffer
commentStartRegexString = _.escapeRegExp(commentStartString).replace(/(\s+)$/, '(?:$1)?')
@@ -247,7 +249,14 @@ class LanguageMode
suggestedIndentForBufferRow: (bufferRow, options) ->
currentIndentLevel = @editor.indentationForBufferRow(bufferRow)
scopeDescriptor = @editor.scopeDescriptorForBufferPosition([bufferRow, 0])
return currentIndentLevel unless increaseIndentRegex = @increaseIndentRegexForScopeDescriptor(scopeDescriptor)
indentPatterns = atom.config.get(scopeDescriptor, 'editor.indent')
if indentPatterns?.increasePattern?
increaseIndentRegex = new OnigRegExp(indentPatterns.increasePattern)
if indentPatterns?.decreasePattern?
decreaseIndentRegex = new OnigRegExp(indentPatterns.decreasePattern)
return currentIndentLevel unless increaseIndentRegex?
currentLine = @buffer.lineForRow(bufferRow)
if options?.skipBlankLines ? true
@@ -261,7 +270,7 @@ class LanguageMode
desiredIndentLevel = @editor.indentationForBufferRow(precedingRow)
desiredIndentLevel += 1 if increaseIndentRegex.testSync(precedingLine) and not @editor.isBufferRowCommented(precedingRow)
return desiredIndentLevel unless decreaseIndentRegex = @decreaseIndentRegexForScopeDescriptor(scopeDescriptor)
return desiredIndentLevel unless decreaseIndentRegex?
desiredIndentLevel -= 1 if decreaseIndentRegex.testSync(currentLine)
Math.max(desiredIndentLevel, 0)
@@ -297,8 +306,13 @@ class LanguageMode
# bufferRow - The row {Number}
autoDecreaseIndentForBufferRow: (bufferRow) ->
scopeDescriptor = @editor.scopeDescriptorForBufferPosition([bufferRow, 0])
increaseIndentRegex = @increaseIndentRegexForScopeDescriptor(scopeDescriptor)
decreaseIndentRegex = @decreaseIndentRegexForScopeDescriptor(scopeDescriptor)
indentPatterns = atom.config.get(scopeDescriptor, 'editor.indent')
if indentPatterns?.increasePattern?
increaseIndentRegex = new OnigRegExp(indentPatterns.increasePattern)
if indentPatterns?.decreasePattern?
decreaseIndentRegex = new OnigRegExp(indentPatterns.decreasePattern)
return unless increaseIndentRegex and decreaseIndentRegex
line = @buffer.lineForRow(bufferRow)
@@ -319,11 +333,5 @@ class LanguageMode
if pattern = atom.config.get(scopeDescriptor, property)
new OnigRegExp(pattern)
increaseIndentRegexForScopeDescriptor: (scopeDescriptor) ->
@getRegexForProperty(scopeDescriptor, 'editor.increaseIndentPattern')
decreaseIndentRegexForScopeDescriptor: (scopeDescriptor) ->
@getRegexForProperty(scopeDescriptor, 'editor.decreaseIndentPattern')
foldEndRegexForScopeDescriptor: (scopeDescriptor) ->
@getRegexForProperty(scopeDescriptor, 'editor.foldEndPattern')
+26
Ver Arquivo
@@ -1,3 +1,4 @@
Grim = require 'grim'
CSON = require 'season'
{CompositeDisposable} = require 'event-kit'
@@ -11,6 +12,31 @@ class ScopedProperties
callback(null, new ScopedProperties(scopedPropertiesPath, scopedProperties))
constructor: (@path, @scopedProperties) ->
for selector, properties of @scopedProperties
if properties.editor?.commentStart?
properties.editor.comment ?= {}
properties.editor.comment.start ?= properties.editor.commentStart
delete properties.editor.commentStart
Grim.deprecate("The 'editor.commentStart' setting has been moved to 'editor.comment.start'. Please update `#{@path}`.")
if properties.editor?.commentEnd?
properties.editor.comment ?= {}
properties.editor.comment.end ?= properties.editor.commentEnd
delete properties.editor.commentEnd
Grim.deprecate("The 'editor.commentEnd' setting has been moved to 'editor.comment.end'. Please update `#{@path}`.")
if properties.editor?.increaseIndentPattern?
properties.editor.indent ?= {}
properties.editor.indent.increasePattern ?= properties.editor.increaseIndentPattern
delete properties.editor.increaseIndentPattern
Grim.deprecate("The 'editor.increaseIndentPattern' setting has been moved to 'editor.indent.increasePattern'. Please update `#{@path}`.")
if properties.editor?.decreaseIndentPattern?
properties.editor.indent ?= {}
properties.editor.indent.decreasePattern ?= properties.editor.decreaseIndentPattern
delete properties.editor.decreaseIndentPattern
Grim.deprecate("The 'editor.decreaseIndentPattern' setting has been moved to 'editor.indent.decreasePattern'. Please update `#{@path}`.")
@propertyDisposable = new CompositeDisposable
activate: ->
+25 -10
Ver Arquivo
@@ -1310,33 +1310,48 @@ class TextEditor extends Model
# Extended: Get all decorations.
#
# * `propertyFilter` (optional) An {Object} containing key value pairs that
# the returned decorations' properties must match.
#
# Returns an {Array} of {Decoration}s.
getDecorations: ->
@displayBuffer.getDecorations()
getDecorations: (propertyFilter) ->
@displayBuffer.getDecorations(propertyFilter)
# Extended: Get all decorations of type 'line'.
#
# * `propertyFilter` (optional) An {Object} containing key value pairs that
# the returned decorations' properties must match.
#
# Returns an {Array} of {Decoration}s.
getLineDecorations: ->
@displayBuffer.getLineDecorations()
getLineDecorations: (propertyFilter) ->
@displayBuffer.getLineDecorations(propertyFilter)
# Extended: Get all decorations of type 'gutter'.
#
# * `propertyFilter` (optional) An {Object} containing key value pairs that
# the returned decorations' properties must match.
#
# Returns an {Array} of {Decoration}s.
getGutterDecorations: ->
@displayBuffer.getGutterDecorations()
getGutterDecorations: (propertyFilter) ->
@displayBuffer.getGutterDecorations(propertyFilter)
# Extended: Get all decorations of type 'highlight'.
#
# * `propertyFilter` (optional) An {Object} containing key value pairs that
# the returned decorations' properties must match.
#
# Returns an {Array} of {Decoration}s.
getHighlightDecorations: ->
@displayBuffer.getHighlightDecorations()
getHighlightDecorations: (propertyFilter) ->
@displayBuffer.getHighlightDecorations(propertyFilter)
# Extended: Get all decorations of type 'overlay'.
#
# * `propertyFilter` (optional) An {Object} containing key value pairs that
# the returned decorations' properties must match.
#
# Returns an {Array} of {Decoration}s.
getOverlayDecorations: ->
@displayBuffer.getOverlayDecorations()
getOverlayDecorations: (propertyFilter) ->
@displayBuffer.getOverlayDecorations(propertyFilter)
decorationForId: (id) ->
@displayBuffer.decorationForId(id)
+1 -1
Ver Arquivo
@@ -150,7 +150,7 @@ atom.commands.add 'atom-workspace',
'window:focus-pane-on-right': -> @focusPaneViewOnRight()
'window:save-all': -> @getModel().saveAll()
'window:toggle-invisibles': -> atom.config.toggle("editor.showInvisibles")
'window:log-deprecation-warnings': -> Grim.logDeprecationWarnings()
'window:log-deprecation-warnings': -> Grim.logDeprecations()
'window:toggle-auto-indent': -> atom.config.toggle("editor.autoIndent")
'pane:reopen-closed-item': -> @getModel().reopenItem()
'core:close': -> @getModel().destroyActivePaneItemOrEmptyPane()