mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge remote-tracking branch 'origin/master' into cj-deleted-files-not-modified
This commit is contained in:
@@ -66,7 +66,7 @@ directory, which contains CoffeeScript-style JSON:
|
||||
|
||||
```coffeescript
|
||||
core:
|
||||
hideGitIgnoredFiles: true
|
||||
excludeVcsIgnoredPaths: true
|
||||
editor:
|
||||
fontSize: 18
|
||||
```
|
||||
@@ -79,7 +79,6 @@ namespaces: `core` and `editor`.
|
||||
- `core`
|
||||
- `disabledPackages`: An array of package names to disable
|
||||
- `excludeVcsIgnoredPaths`: Don't search within files specified by _.gitignore_
|
||||
- `hideGitIgnoredFiles`: Whether files in the _.gitignore_ should be hidden
|
||||
- `ignoredNames`: File names to ignore across all of Atom
|
||||
- `projectHome`: The directory where projects are assumed to be located
|
||||
- `themes`: An array of theme names to load, in cascading order
|
||||
@@ -107,7 +106,7 @@ namespaces: `core` and `editor`.
|
||||
- `whitespace`
|
||||
- `ensureSingleTrailingNewline`: Whether to reduce multiple newlines to one at the end of files
|
||||
- `removeTrailingWhitespace`: Enable/disable striping of whitespace at the end of lines (defaults to `true`)
|
||||
- `wrapGuide`
|
||||
- `wrap-guide`
|
||||
- `columns`: Array of hashes with a `pattern` and `column` key to match the
|
||||
the path of the current editor to a column position.
|
||||
|
||||
|
||||
35
package.json
35
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "atom",
|
||||
"productName": "Atom",
|
||||
"version": "0.42.0",
|
||||
"version": "0.44.0",
|
||||
"main": "./src/browser/main.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -36,16 +36,16 @@
|
||||
"nslog": "0.1.0",
|
||||
"oniguruma": "0.24.0",
|
||||
"optimist": "0.4.0",
|
||||
"pathwatcher": "0.10.0",
|
||||
"pathwatcher": "0.11.0",
|
||||
"pegjs": "0.7.0",
|
||||
"q": "0.9.7",
|
||||
"scandal": "0.8.0",
|
||||
"season": "0.14.0",
|
||||
"semver": "1.1.4",
|
||||
"space-pen": "2.0.1",
|
||||
"telepath": "0.61.0",
|
||||
"telepath": "0.65.0",
|
||||
"temp": "0.5.0",
|
||||
"underscore-plus": "0.3.0"
|
||||
"underscore-plus": "0.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"biscotto": "0.0.17",
|
||||
@@ -69,15 +69,16 @@
|
||||
"request": "~2.27.0",
|
||||
"unzip": "~0.1.9",
|
||||
"rcedit": "~0.1.2",
|
||||
"rimraf": "~2.2.2"
|
||||
"rimraf": "~2.2.2",
|
||||
"github-releases": "~0.2.0"
|
||||
},
|
||||
"packageDependencies": {
|
||||
"atom-dark-syntax": "0.8.0",
|
||||
"atom-dark-ui": "0.13.0",
|
||||
"atom-dark-ui": "0.14.0",
|
||||
"atom-light-syntax": "0.9.0",
|
||||
"atom-light-ui": "0.13.0",
|
||||
"base16-tomorrow-dark-theme": "0.6.0",
|
||||
"solarized-dark-syntax": "0.4.0",
|
||||
"atom-light-ui": "0.14.0",
|
||||
"base16-tomorrow-dark-theme": "0.7.0",
|
||||
"solarized-dark-syntax": "0.5.0",
|
||||
"archive-view": "0.16.0",
|
||||
"autocomplete": "0.18.0",
|
||||
"autoflow": "0.11.0",
|
||||
@@ -85,14 +86,14 @@
|
||||
"bookmarks": "0.15.0",
|
||||
"bracket-matcher": "0.15.0",
|
||||
"command-logger": "0.8.0",
|
||||
"command-palette": "0.11.0",
|
||||
"command-palette": "0.13.0",
|
||||
"dev-live-reload": "0.18.0",
|
||||
"editor-stats": "0.8.0",
|
||||
"exception-reporting": "0.8.0",
|
||||
"feedback": "0.15.0",
|
||||
"find-and-replace": "0.55.0",
|
||||
"fuzzy-finder": "0.27.0",
|
||||
"gists": "0.12.0",
|
||||
"feedback": "0.16.0",
|
||||
"find-and-replace": "0.58.0",
|
||||
"fuzzy-finder": "0.28.0",
|
||||
"gists": "0.13.0",
|
||||
"git-diff": "0.20.0",
|
||||
"github-sign-in": "0.15.0",
|
||||
"go-to-line": "0.12.0",
|
||||
@@ -108,7 +109,7 @@
|
||||
"snippets": "0.17.0",
|
||||
"spell-check": "0.17.0",
|
||||
"status-bar": "0.24.0",
|
||||
"styleguide": "0.17.0",
|
||||
"styleguide": "0.18.0",
|
||||
"symbols-view": "0.27.0",
|
||||
"tabs": "0.15.0",
|
||||
"terminal": "0.23.0",
|
||||
@@ -118,12 +119,12 @@
|
||||
"visual-bell": "0.6.0",
|
||||
"welcome": "0.3.0",
|
||||
"whitespace": "0.10.0",
|
||||
"wrap-guide": "0.8.0",
|
||||
"wrap-guide": "0.10.0",
|
||||
"language-c": "0.2.0",
|
||||
"language-clojure": "0.1.0",
|
||||
"language-coffee-script": "0.3.0",
|
||||
"language-css": "0.2.0",
|
||||
"language-gfm": "0.9.0",
|
||||
"language-gfm": "0.10.0",
|
||||
"language-git": "0.3.0",
|
||||
"language-go": "0.2.0",
|
||||
"language-html": "0.2.0",
|
||||
|
||||
@@ -22,17 +22,11 @@ function executeCommands(commands, done, index) {
|
||||
done(null);
|
||||
}
|
||||
|
||||
// Join multiple commands into one line.
|
||||
function joinCommands() {
|
||||
var commandSeparator = process.platform == 'win32' ? '&' : ';';
|
||||
return Array.prototype.slice.call(arguments, 0).join(commandSeparator);
|
||||
}
|
||||
|
||||
var echoNewLine = process.platform == 'win32' ? 'echo.' : 'echo';
|
||||
var commands = [
|
||||
'git submodule --quiet sync',
|
||||
'git submodule --quiet update --recursive --init',
|
||||
{command: joinCommands('cd vendor/apm', 'npm install --silent .'), options: {ignoreStdout: true}},
|
||||
{command: 'npm install --silent .', options: {cwd: path.resolve(__dirname, '..', 'vendor', 'apm'), ignoreStdout: true}},
|
||||
{command: 'npm install --silent vendor/apm', options: {ignoreStdout: true}},
|
||||
echoNewLine,
|
||||
'node node_modules/atom-package-manager/bin/apm clean',
|
||||
|
||||
@@ -33,6 +33,7 @@ cp.safeExec.bind(global, 'node script/bootstrap', function(error) {
|
||||
require('rimraf').bind(global, path.join(homeDir, '.atom')),
|
||||
cp.safeExec.bind(global, 'git clean -dff'),
|
||||
cp.safeExec.bind(global, 'node node_modules/grunt-cli/bin/grunt ci --stack --no-color'),
|
||||
cp.safeExec.bind(global, 'node_modules/.bin/coffee script/upload-release')
|
||||
], function(error) {
|
||||
process.exit(error ? 1 : 0);
|
||||
});
|
||||
|
||||
83
script/upload-release
Executable file
83
script/upload-release
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env coffee
|
||||
|
||||
return if process.env.JANKY_SHA1 and process.env.JANKY_BRANCH isnt 'master'
|
||||
|
||||
child_process = require 'child_process'
|
||||
path = require 'path'
|
||||
|
||||
fs = require 'fs-plus'
|
||||
GitHub = require 'github-releases'
|
||||
request = require 'request'
|
||||
|
||||
assetPath = '/tmp/atom-build/atom-mac.zip'
|
||||
token = process.env.ATOM_ACCESS_TOKEN
|
||||
|
||||
zipApp = (callback) ->
|
||||
fs.removeSync(assetPath)
|
||||
|
||||
options = {cwd: path.dirname(assetPath), maxBuffer: Infinity}
|
||||
child_process.exec "zip -r --symlinks #{path.basename(assetPath)} Atom.app", options, (error, stdout, stderr) ->
|
||||
if error?
|
||||
console.error('Zipping Atom.app failed', error, stderr)
|
||||
process.exit(1)
|
||||
else
|
||||
callback()
|
||||
|
||||
getDraftRelease = (callback) ->
|
||||
github = new GitHub({repo: 'atom/atom', token})
|
||||
github.getReleases (error, releases=[]) ->
|
||||
if error?
|
||||
console.error('Fetching releases failed', error.message, error.stack)
|
||||
process.exit(1)
|
||||
|
||||
if releases.length is 0
|
||||
console.error('No releases found in atom/atom repo')
|
||||
process.exit(1)
|
||||
|
||||
for release in releases when release.draft
|
||||
callback(release)
|
||||
return
|
||||
|
||||
console.error('No draft release found in atom/atom repo')
|
||||
process.exit(1)
|
||||
|
||||
deleteExistingAsset = (release, callback) ->
|
||||
for asset in release.assets when asset.name is path.basename(assetPath)
|
||||
options =
|
||||
uri: asset.url
|
||||
method: 'DELETE'
|
||||
headers:
|
||||
Authorization: "token #{token}"
|
||||
'User-Agent': 'Atom'
|
||||
request options, (error, response, body='') ->
|
||||
if error? or response.statusCode >= 400
|
||||
console.error('Deleting existing release asset failed', error, body)
|
||||
process.exit(1)
|
||||
else
|
||||
callback()
|
||||
|
||||
return
|
||||
|
||||
callback()
|
||||
|
||||
uploadAsset = (release) ->
|
||||
options =
|
||||
uri: "https://uploads.github.com/repos/atom/atom/releases/#{release.id}/assets?name=#{path.basename(assetPath)}"
|
||||
method: 'POST'
|
||||
headers:
|
||||
Authorization: "token #{token}"
|
||||
'Content-Type': 'application/zip'
|
||||
'Content-Length': fs.getSizeSync(assetPath)
|
||||
'User-Agent': 'Atom'
|
||||
|
||||
assetRequest = request options, (error, response, body='') ->
|
||||
if error? or response.statusCode >= 400
|
||||
console.error('Upload release asset failed', error, body)
|
||||
process.exit(1)
|
||||
fs.createReadStream(assetPath).pipe(assetRequest)
|
||||
|
||||
getDraftRelease (release) ->
|
||||
console.log("Uploading #{path.basename(assetPath)} asset to #{release.tag_name} (#{release.name}) release")
|
||||
zipApp ->
|
||||
deleteExistingAsset release, ->
|
||||
uploadAsset(release)
|
||||
@@ -7,7 +7,7 @@ describe "DisplayBuffer", ->
|
||||
tabLength = 2
|
||||
atom.packages.activatePackage('language-javascript', sync: true)
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
displayBuffer = new DisplayBuffer({buffer, tabLength})
|
||||
displayBuffer = atom.create(new DisplayBuffer({buffer, tabLength}))
|
||||
changeHandler = jasmine.createSpy 'changeHandler'
|
||||
displayBuffer.on 'changed', changeHandler
|
||||
|
||||
@@ -15,19 +15,6 @@ describe "DisplayBuffer", ->
|
||||
displayBuffer.destroy()
|
||||
buffer.release()
|
||||
|
||||
describe "@deserialize(state)", ->
|
||||
it "constructs a display buffer with the same buffer, folds, editorWidthInChars, and tabLength", ->
|
||||
displayBuffer.setTabLength(4)
|
||||
displayBuffer.setEditorWidthInChars(64)
|
||||
displayBuffer.createFold(2, 4)
|
||||
displayBuffer2 = atom.deserializers.deserialize(displayBuffer.serialize())
|
||||
expect(displayBuffer2.id).toBe displayBuffer.id
|
||||
expect(displayBuffer2.buffer).toBe displayBuffer.buffer
|
||||
expect(displayBuffer2.tokenizedBuffer.buffer).toBe displayBuffer.tokenizedBuffer.buffer
|
||||
expect(displayBuffer2.isFoldedAtBufferRow(2)).toBeTruthy()
|
||||
expect(displayBuffer2.getSoftWrapColumn()).toBe displayBuffer.getSoftWrapColumn()
|
||||
expect(displayBuffer2.getTabLength()).toBe displayBuffer.getTabLength()
|
||||
|
||||
describe ".copy()", ->
|
||||
it "creates a new DisplayBuffer with the same initial state", ->
|
||||
marker1 = displayBuffer.markBufferRange([[1, 2], [3, 4]], id: 1)
|
||||
@@ -155,7 +142,7 @@ describe "DisplayBuffer", ->
|
||||
describe "when a newline is inserted, deleted, and re-inserted at the end of a wrapped line (regression)", ->
|
||||
it "correctly renders the original wrapped line", ->
|
||||
buffer = atom.project.buildBufferSync(null, '')
|
||||
displayBuffer = new DisplayBuffer({buffer, tabLength, editorWidthInChars: 30, softWrap: true})
|
||||
displayBuffer = atom.create(new DisplayBuffer({buffer, tabLength, editorWidthInChars: 30, softWrap: true}))
|
||||
|
||||
buffer.insert([0, 0], "the quick brown fox jumps over the lazy dog.")
|
||||
buffer.insert([0, Infinity], '\n')
|
||||
@@ -207,7 +194,7 @@ describe "DisplayBuffer", ->
|
||||
displayBuffer.destroy()
|
||||
buffer.release()
|
||||
buffer = atom.project.bufferForPathSync('two-hundred.txt')
|
||||
displayBuffer = new DisplayBuffer({buffer, tabLength})
|
||||
displayBuffer = atom.create(new DisplayBuffer({buffer, tabLength}))
|
||||
displayBuffer.on 'changed', changeHandler
|
||||
|
||||
describe "when folds are created and destroyed", ->
|
||||
@@ -313,7 +300,7 @@ describe "DisplayBuffer", ->
|
||||
|
||||
describe "when there is another display buffer pointing to the same buffer", ->
|
||||
it "does not create folds in the other display buffer", ->
|
||||
otherDisplayBuffer = new DisplayBuffer({buffer, tabLength})
|
||||
otherDisplayBuffer = atom.create(new DisplayBuffer({buffer, tabLength}))
|
||||
displayBuffer.createFold(2, 4)
|
||||
expect(otherDisplayBuffer.foldsStartingAtBufferRow(2).length).toBe 0
|
||||
|
||||
|
||||
@@ -2389,17 +2389,16 @@ describe "Editor", ->
|
||||
|
||||
describe "when a better-matched grammar is added to syntax", ->
|
||||
it "switches to the better-matched grammar and re-tokenizes the buffer", ->
|
||||
editor.destroy()
|
||||
jsGrammar = atom.syntax.selectGrammar('a.js')
|
||||
atom.syntax.removeGrammar(jsGrammar)
|
||||
|
||||
editor = atom.project.openSync('sample.js', autoIndent: false)
|
||||
expect(editor.getGrammar()).toBe atom.syntax.nullGrammar
|
||||
expect(editor.lineForScreenRow(0).tokens.length).toBe 1
|
||||
editor2 = atom.project.openSync('sample.js', autoIndent: false)
|
||||
expect(editor2.getGrammar()).toBe atom.syntax.nullGrammar
|
||||
expect(editor2.lineForScreenRow(0).tokens.length).toBe 1
|
||||
|
||||
atom.syntax.addGrammar(jsGrammar)
|
||||
expect(editor.getGrammar()).toBe jsGrammar
|
||||
expect(editor.lineForScreenRow(0).tokens.length).toBeGreaterThan 1
|
||||
expect(editor2.getGrammar()).toBe jsGrammar
|
||||
expect(editor2.lineForScreenRow(0).tokens.length).toBeGreaterThan 1
|
||||
|
||||
describe "auto-indent", ->
|
||||
copyText = (text, {startColumn}={}) ->
|
||||
|
||||
@@ -698,18 +698,16 @@ describe "Pane", ->
|
||||
expect(newPane.items.length).toBe pane.items.length - 1
|
||||
|
||||
it "focuses the pane after attach only if had focus when serialized", ->
|
||||
reloadContainer = ->
|
||||
containerState = container.serialize()
|
||||
container.remove()
|
||||
container = atom.deserializers.deserialize(containerState)
|
||||
pane = container.getRoot()
|
||||
container.attachToDom()
|
||||
|
||||
container.attachToDom()
|
||||
pane.focus()
|
||||
reloadContainer()
|
||||
expect(pane).toMatchSelector(':has(:focus)')
|
||||
|
||||
container2 = atom.deserializers.deserialize(container.serialize())
|
||||
pane2 = container2.getRoot()
|
||||
container2.attachToDom()
|
||||
expect(pane2).toMatchSelector(':has(:focus)')
|
||||
|
||||
$(document.activeElement).blur()
|
||||
reloadContainer()
|
||||
expect(pane).not.toMatchSelector(':has(:focus)')
|
||||
container3 = atom.deserializers.deserialize(container.serialize())
|
||||
pane3 = container3.getRoot()
|
||||
container3.attachToDom()
|
||||
expect(pane3).not.toMatchSelector(':has(:focus)')
|
||||
|
||||
@@ -53,15 +53,15 @@ describe "SpacePen extensions", ->
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
|
||||
describe "tooltips", ->
|
||||
describe "replaceModifiers", ->
|
||||
replaceModifiers = $.fn.setTooltip.replaceModifiers
|
||||
describe "humanizeKeystrokes", ->
|
||||
humanizeKeystrokes = $.fn.setTooltip.humanizeKeystrokes
|
||||
|
||||
it "replaces single keystroke", ->
|
||||
expect(replaceModifiers('cmd-O')).toEqual '⌘⇧O'
|
||||
expect(replaceModifiers('cmd-shift-up')).toEqual '⌘⇧↑'
|
||||
expect(replaceModifiers('cmd-option-down')).toEqual '⌘⌥↓'
|
||||
expect(replaceModifiers('cmd-option-left')).toEqual '⌘⌥←'
|
||||
expect(replaceModifiers('cmd-option-right')).toEqual '⌘⌥→'
|
||||
expect(humanizeKeystrokes('cmd-O')).toEqual '⌘⇧O'
|
||||
expect(humanizeKeystrokes('cmd-shift-up')).toEqual '⌘⇧↑'
|
||||
expect(humanizeKeystrokes('cmd-option-down')).toEqual '⌘⌥↓'
|
||||
expect(humanizeKeystrokes('cmd-option-left')).toEqual '⌘⌥←'
|
||||
expect(humanizeKeystrokes('cmd-option-right')).toEqual '⌘⌥→'
|
||||
|
||||
it "replaces multiple keystroke", ->
|
||||
expect(replaceModifiers('cmd-o ctrl-2')).toEqual '⌘O ⌃2'
|
||||
expect(humanizeKeystrokes('cmd-o ctrl-2')).toEqual '⌘O ⌃2'
|
||||
|
||||
@@ -18,22 +18,14 @@ describe "TokenizedBuffer", ->
|
||||
advanceClock() while tokenizedBuffer.firstInvalidRow()?
|
||||
changeHandler?.reset()
|
||||
|
||||
describe "@deserialize(state)", ->
|
||||
it "constructs a tokenized buffer with the same buffer and tabLength setting", ->
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
tokenizedBuffer1 = new TokenizedBuffer(buffer: buffer, tabLength: 4)
|
||||
tokenizedBuffer2 = atom.deserializers.deserialize(tokenizedBuffer1.serialize())
|
||||
expect(tokenizedBuffer2.buffer).toBe tokenizedBuffer1.buffer
|
||||
expect(tokenizedBuffer2.getTabLength()).toBe tokenizedBuffer1.getTabLength()
|
||||
|
||||
describe "when the buffer is destroyed", ->
|
||||
beforeEach ->
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
startTokenizing(tokenizedBuffer)
|
||||
|
||||
it "stops tokenization", ->
|
||||
tokenizedBuffer.destroy()
|
||||
tokenizedBuffer.state.destroy()
|
||||
spyOn(tokenizedBuffer, 'tokenizeNextChunk')
|
||||
advanceClock()
|
||||
expect(tokenizedBuffer.tokenizeNextChunk).not.toHaveBeenCalled()
|
||||
@@ -41,7 +33,7 @@ describe "TokenizedBuffer", ->
|
||||
describe "when the buffer contains soft-tabs", ->
|
||||
beforeEach ->
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
startTokenizing(tokenizedBuffer)
|
||||
tokenizedBuffer.on "changed", changeHandler = jasmine.createSpy('changeHandler')
|
||||
|
||||
@@ -321,7 +313,7 @@ describe "TokenizedBuffer", ->
|
||||
beforeEach ->
|
||||
atom.packages.activatePackage('language-coffee-script', sync: true)
|
||||
buffer = atom.project.bufferForPathSync('sample-with-tabs.coffee')
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
startTokenizing(tokenizedBuffer)
|
||||
|
||||
afterEach ->
|
||||
@@ -355,7 +347,7 @@ describe "TokenizedBuffer", ->
|
||||
'abc\uD835\uDF97def'
|
||||
//\uD835\uDF97xyz
|
||||
"""
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
|
||||
afterEach ->
|
||||
@@ -392,7 +384,7 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
buffer = atom.project.bufferForPathSync()
|
||||
buffer.setText "<div class='name'><%= User.find(2).full_name %></div>"
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
tokenizedBuffer.setGrammar(atom.syntax.selectGrammar('test.erb'))
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
|
||||
@@ -411,7 +403,7 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
it "returns the correct token (regression)", ->
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
expect(tokenizedBuffer.tokenForPosition([1,0]).scopes).toEqual ["source.js"]
|
||||
expect(tokenizedBuffer.tokenForPosition([1,1]).scopes).toEqual ["source.js"]
|
||||
@@ -420,7 +412,7 @@ describe "TokenizedBuffer", ->
|
||||
describe ".bufferRangeForScopeAtPosition(selector, position)", ->
|
||||
beforeEach ->
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
|
||||
describe "when the selector does not match the token at the position", ->
|
||||
@@ -439,7 +431,7 @@ describe "TokenizedBuffer", ->
|
||||
it "updates the tab length of the tokenized lines", ->
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
buffer.setText('\ttest')
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer = atom.create(new TokenizedBuffer({buffer}))
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' '
|
||||
atom.config.set('editor.tabLength', 6)
|
||||
|
||||
@@ -41,6 +41,7 @@ class Atom
|
||||
|
||||
# Private:
|
||||
constructor: ->
|
||||
@loadTime = null
|
||||
@workspaceViewParentSelector = 'body'
|
||||
@deserializers = new DeserializerManager()
|
||||
|
||||
@@ -80,6 +81,12 @@ class Atom
|
||||
setBodyPlatformClass: ->
|
||||
document.body.classList.add("platform-#{process.platform}")
|
||||
|
||||
# Public: Create a new telepath model. We won't need to define this method when
|
||||
# the atom global is a telepath model itself because all model subclasses inherit
|
||||
# a create method.
|
||||
create: (model) ->
|
||||
@site.createDocument(model)
|
||||
|
||||
# Public: Get the current window
|
||||
getCurrentWindow: ->
|
||||
remote.getCurrentWindow()
|
||||
@@ -420,7 +427,7 @@ class Atom
|
||||
serializedWindowState = @loadSerializedWindowState()
|
||||
doc = Document.deserialize(serializedWindowState) if serializedWindowState?
|
||||
doc ?= Document.create()
|
||||
doc.registerModelClasses(require('./text-buffer'), require('./project'))
|
||||
doc.registerModelClasses(require('./text-buffer'), require('./project'), require('./tokenized-buffer'), require('./display-buffer'))
|
||||
# TODO: Remove this when everything is using telepath models
|
||||
if @site?
|
||||
@site.setRootDocument(doc)
|
||||
@@ -444,6 +451,16 @@ class Atom
|
||||
else
|
||||
@windowState
|
||||
|
||||
# Public: Get the time taken to completely load the current window.
|
||||
#
|
||||
# This time include things like loading and activating packages, creating
|
||||
# DOM elements for the editor, and reading the config.
|
||||
#
|
||||
# Returns the number of milliseconds taken to load the window or null
|
||||
# if the window hasn't finished loading yet.
|
||||
getWindowLoadTime: ->
|
||||
@loadTime
|
||||
|
||||
# Private: Returns a replicated copy of the current state.
|
||||
replicate: ->
|
||||
@getWindowState().replicate()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
_ = require 'underscore-plus'
|
||||
{Emitter, Subscriber} = require 'emissary'
|
||||
guid = require 'guid'
|
||||
telepath = require 'telepath'
|
||||
{Point, Range} = telepath
|
||||
{Model, Point, Range} = require 'telepath'
|
||||
TokenizedBuffer = require './tokenized-buffer'
|
||||
RowMap = require './row-map'
|
||||
Fold = require './fold'
|
||||
@@ -12,34 +11,28 @@ ConfigObserver = require './config-observer'
|
||||
|
||||
# Private:
|
||||
module.exports =
|
||||
class DisplayBuffer
|
||||
Emitter.includeInto(this)
|
||||
Subscriber.includeInto(this)
|
||||
class DisplayBuffer extends Model
|
||||
_.extend @prototype, ConfigObserver
|
||||
|
||||
@acceptsDocuments: true
|
||||
atom.deserializers.add(this)
|
||||
@version: 2
|
||||
@properties
|
||||
tokenizedBuffer: null
|
||||
softWrap: -> atom.config.get('editor.softWrap') ? false
|
||||
editorWidthInChars: null
|
||||
|
||||
@deserialize: (state) -> new this(state)
|
||||
constructor: ->
|
||||
super
|
||||
@deserializing = @state?
|
||||
|
||||
constructor: (optionsOrState) ->
|
||||
if optionsOrState instanceof telepath.Document
|
||||
@state = optionsOrState
|
||||
@id = @state.get('id')
|
||||
@tokenizedBuffer = atom.deserializers.deserialize(@state.get('tokenizedBuffer'))
|
||||
@buffer = @tokenizedBuffer.buffer
|
||||
created: ->
|
||||
if @deserializing
|
||||
@deserializing = false
|
||||
return
|
||||
|
||||
if @tokenizedBuffer?
|
||||
@tokenizedBuffer?.created()
|
||||
else
|
||||
{@buffer, softWrap, editorWidthInChars} = optionsOrState
|
||||
@id = guid.create().toString()
|
||||
@tokenizedBuffer = new TokenizedBuffer(optionsOrState)
|
||||
@state = atom.site.createDocument
|
||||
deserializer: @constructor.name
|
||||
version: @constructor.version
|
||||
id: @id
|
||||
tokenizedBuffer: @tokenizedBuffer.getState()
|
||||
softWrap: softWrap ? atom.config.get('editor.softWrap') ? false
|
||||
editorWidthInChars: editorWidthInChars
|
||||
@tokenizedBuffer = new TokenizedBuffer({@tabLength, @buffer, project: atom.project})
|
||||
@buffer = @tokenizedBuffer.buffer
|
||||
|
||||
@markers = {}
|
||||
@foldsByMarkerId = {}
|
||||
@@ -56,16 +49,13 @@ class DisplayBuffer
|
||||
@updateWrappedScreenLines()
|
||||
|
||||
@observeConfig 'editor.preferredLineLength', callNow: false, =>
|
||||
@updateWrappedScreenLines() if @getSoftWrap() and atom.config.get('editor.softWrapAtPreferredLineLength')
|
||||
@updateWrappedScreenLines() if @softWrap and atom.config.get('editor.softWrapAtPreferredLineLength')
|
||||
|
||||
@observeConfig 'editor.softWrapAtPreferredLineLength', callNow: false, =>
|
||||
@updateWrappedScreenLines() if @getSoftWrap()
|
||||
|
||||
serialize: -> @state.clone()
|
||||
getState: -> @state
|
||||
@updateWrappedScreenLines() if @softWrap
|
||||
|
||||
copy: ->
|
||||
newDisplayBuffer = new DisplayBuffer({@buffer, tabLength: @getTabLength()})
|
||||
newDisplayBuffer = atom.create(new DisplayBuffer({@buffer, tabLength: @getTabLength()}))
|
||||
for marker in @findMarkers(displayBufferId: @id)
|
||||
marker.copy(displayBufferId: newDisplayBuffer.id)
|
||||
newDisplayBuffer
|
||||
@@ -98,25 +88,26 @@ class DisplayBuffer
|
||||
# visible - A {Boolean} indicating of the tokenized buffer is shown
|
||||
setVisible: (visible) -> @tokenizedBuffer.setVisible(visible)
|
||||
|
||||
setSoftWrap: (softWrap) -> @state.set('softWrap', softWrap)
|
||||
# Deprecated: Use the softWrap property directly
|
||||
setSoftWrap: (@softWrap) -> @softWrap
|
||||
|
||||
getSoftWrap: -> @state.get('softWrap')
|
||||
# Deprecated: Use the softWrap property directly
|
||||
getSoftWrap: -> @softWrap
|
||||
|
||||
# Set the number of characters that fit horizontally in the editor.
|
||||
#
|
||||
# editorWidthInChars - A {Number} of characters.
|
||||
setEditorWidthInChars: (editorWidthInChars) ->
|
||||
previousWidthInChars = @state.get('editorWidthInChars')
|
||||
@state.set('editorWidthInChars', editorWidthInChars)
|
||||
if editorWidthInChars isnt previousWidthInChars and @getSoftWrap()
|
||||
previousWidthInChars = @editorWidthInChars
|
||||
@editorWidthInChars = editorWidthInChars
|
||||
if editorWidthInChars isnt previousWidthInChars and @softWrap
|
||||
@updateWrappedScreenLines()
|
||||
|
||||
getSoftWrapColumn: ->
|
||||
editorWidthInChars = @state.get('editorWidthInChars')
|
||||
if atom.config.get('editor.softWrapAtPreferredLineLength')
|
||||
Math.min(editorWidthInChars, atom.config.getPositiveInt('editor.preferredLineLength', editorWidthInChars))
|
||||
Math.min(@editorWidthInChars, atom.config.getPositiveInt('editor.preferredLineLength', @editorWidthInChars))
|
||||
else
|
||||
editorWidthInChars
|
||||
@editorWidthInChars
|
||||
|
||||
# Gets the screen line for the given screen row.
|
||||
#
|
||||
@@ -433,7 +424,7 @@ class DisplayBuffer
|
||||
# Returns a {Number} representing the `line` position where the wrap would take place.
|
||||
# Returns `null` if a wrap wouldn't occur.
|
||||
findWrapColumn: (line, softWrapColumn=@getSoftWrapColumn()) ->
|
||||
return unless @getSoftWrap()
|
||||
return unless @softWrap
|
||||
return unless line.length > softWrapColumn
|
||||
|
||||
if /\s/.test(line[softWrapColumn])
|
||||
@@ -654,6 +645,7 @@ class DisplayBuffer
|
||||
softWraps = 0
|
||||
while wrapScreenColumn = @findWrapColumn(tokenizedLine.text)
|
||||
[wrappedLine, tokenizedLine] = tokenizedLine.softWrapAt(wrapScreenColumn)
|
||||
|
||||
newScreenLines.push(wrappedLine)
|
||||
softWraps++
|
||||
newScreenLines.push(tokenizedLine)
|
||||
|
||||
@@ -106,7 +106,7 @@ class EditorView extends View
|
||||
@edit(editor)
|
||||
else if @mini
|
||||
@edit(new Editor
|
||||
buffer: TextBuffer.createAsRoot()
|
||||
buffer: atom.create(new TextBuffer)
|
||||
softWrap: false
|
||||
tabLength: 2
|
||||
softTabs: true
|
||||
|
||||
@@ -44,7 +44,7 @@ class Editor
|
||||
|
||||
atom.deserializers.add(this)
|
||||
|
||||
@version: 5
|
||||
@version: 6
|
||||
|
||||
@deserialize: (state) ->
|
||||
new Editor(state)
|
||||
@@ -67,7 +67,8 @@ class Editor
|
||||
if optionsOrState instanceof telepath.Document
|
||||
@state = optionsOrState
|
||||
@id = @state.get('id')
|
||||
displayBuffer = atom.deserializers.deserialize(@state.get('displayBuffer'))
|
||||
displayBuffer = @state.get('displayBuffer')
|
||||
displayBuffer.created()
|
||||
@setBuffer(displayBuffer.buffer)
|
||||
@setDisplayBuffer(displayBuffer)
|
||||
for marker in @findMarkers(@getSelectionMarkerAttributes())
|
||||
@@ -79,12 +80,12 @@ class Editor
|
||||
else
|
||||
{buffer, displayBuffer, tabLength, softTabs, softWrap, suppressCursorCreation, initialLine} = optionsOrState
|
||||
@id = guid.create().toString()
|
||||
displayBuffer ?= new DisplayBuffer({buffer, tabLength, softWrap})
|
||||
displayBuffer ?= atom.create(new DisplayBuffer({buffer, tabLength, softWrap}))
|
||||
@state = atom.site.createDocument
|
||||
deserializer: @constructor.name
|
||||
version: @constructor.version
|
||||
id: @id
|
||||
displayBuffer: displayBuffer.getState()
|
||||
displayBuffer: displayBuffer
|
||||
softTabs: buffer.usesSoftTabs() ? softTabs ? atom.config.get('editor.softTabs') ? true
|
||||
scrollTop: 0
|
||||
scrollLeft: 0
|
||||
|
||||
@@ -34,7 +34,7 @@ class Project extends telepath.Model
|
||||
# Private: Called by telepath.
|
||||
created: ->
|
||||
for buffer in @buffers.getValues()
|
||||
buffer.once 'destroyed', (buffer) => @removeBuffer(buffer)
|
||||
buffer.once 'destroyed', (buffer) => @removeBuffer(buffer) if @isAlive()
|
||||
|
||||
@openers = []
|
||||
@editors = []
|
||||
@@ -64,7 +64,7 @@ class Project extends telepath.Model
|
||||
# Private:
|
||||
destroyed: ->
|
||||
editor.destroy() for editor in @getEditors()
|
||||
buffer.release() for buffer in @getBuffers()
|
||||
buffer.destroy() for buffer in @getBuffers()
|
||||
@destroyRepo()
|
||||
|
||||
# Private:
|
||||
@@ -239,7 +239,7 @@ class Project extends telepath.Model
|
||||
# Private:
|
||||
addBufferAtIndex: (buffer, index, options={}) ->
|
||||
buffer = @buffers.insert(index, buffer)
|
||||
buffer.once 'destroyed', => @removeBuffer(buffer)
|
||||
buffer.once 'destroyed', => @removeBuffer(buffer) if @isAlive()
|
||||
@emit 'buffer-created', buffer
|
||||
buffer
|
||||
|
||||
|
||||
@@ -24,41 +24,14 @@ tooltipDefaults =
|
||||
placement: 'auto top'
|
||||
viewportPadding: 2
|
||||
|
||||
modifiers =
|
||||
cmd: '⌘'
|
||||
ctrl: '⌃'
|
||||
alt: '⌥'
|
||||
option: '⌥'
|
||||
shift: '⇧'
|
||||
enter: '⏎'
|
||||
left: '←'
|
||||
right: '→'
|
||||
up: '↑'
|
||||
down: '↓'
|
||||
|
||||
replaceKey = (key) ->
|
||||
if modifiers[key]
|
||||
modifiers[key]
|
||||
else if key.length == 1 and key == key.toUpperCase() and key.toUpperCase() != key.toLowerCase()
|
||||
[modifiers.shift, key.toUpperCase()]
|
||||
else if key.length == 1
|
||||
key.toUpperCase()
|
||||
else
|
||||
key
|
||||
|
||||
replaceModifiersInSingleKeystroke = (keystroke) ->
|
||||
keys = keystroke.split('-')
|
||||
keys = _.flatten(replaceKey(key) for key in keys)
|
||||
keys.join('')
|
||||
|
||||
replaceModifiers = (keystroke) ->
|
||||
humanizeKeystrokes = (keystroke) ->
|
||||
keystrokes = keystroke.split(' ')
|
||||
keystrokes = (replaceModifiersInSingleKeystroke(stroke) for stroke in keystrokes)
|
||||
keystrokes = (_.humanizeKeystroke(stroke) for stroke in keystrokes)
|
||||
keystrokes.join(' ')
|
||||
|
||||
getKeystroke = (bindings) ->
|
||||
if bindings?.length
|
||||
"<span class=\"keystroke\">#{replaceModifiers(bindings[0].keystroke)}</span>"
|
||||
"<span class=\"keystroke\">#{humanizeKeystrokes(bindings[0].keystroke)}</span>"
|
||||
else
|
||||
''
|
||||
# options from http://getbootstrap.com/javascript/#tooltips
|
||||
@@ -87,6 +60,6 @@ jQuery.fn.destroyTooltip = ->
|
||||
@tooltip('destroy')
|
||||
|
||||
jQuery.fn.setTooltip.getKeystroke = getKeystroke
|
||||
jQuery.fn.setTooltip.replaceModifiers = replaceModifiers
|
||||
jQuery.fn.setTooltip.humanizeKeystrokes = humanizeKeystrokes
|
||||
|
||||
module.exports = spacePen
|
||||
|
||||
@@ -81,12 +81,12 @@ class TextBuffer extends telepath.Model
|
||||
@emit 'changed', bufferChangeEvent
|
||||
@scheduleModifiedEvents()
|
||||
|
||||
destroy: ->
|
||||
unless @destroyed
|
||||
destroyed: ->
|
||||
unless @alreadyDestroyed
|
||||
@cancelStoppedChangingTimeout()
|
||||
@file?.off()
|
||||
@unsubscribe()
|
||||
@destroyed = true
|
||||
@alreadyDestroyed = true
|
||||
@emit 'destroyed', this
|
||||
|
||||
isRetained: -> @refcount > 0
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
_ = require 'underscore-plus'
|
||||
{Model, Point, Range} = require 'telepath'
|
||||
TokenizedLine = require './tokenized-line'
|
||||
{Emitter, Subscriber} = require 'emissary'
|
||||
Token = require './token'
|
||||
telepath = require 'telepath'
|
||||
{Point, Range} = telepath
|
||||
|
||||
### Internal ###
|
||||
|
||||
module.exports =
|
||||
class TokenizedBuffer
|
||||
Emitter.includeInto(this)
|
||||
Subscriber.includeInto(this)
|
||||
class TokenizedBuffer extends Model
|
||||
@properties
|
||||
bufferPath: null
|
||||
tabLength: -> atom.config.get('editor.tabLength') ? 2
|
||||
project: null
|
||||
|
||||
grammar: null
|
||||
currentGrammarScore: null
|
||||
@@ -20,24 +20,19 @@ class TokenizedBuffer
|
||||
invalidRows: null
|
||||
visible: false
|
||||
|
||||
@acceptsDocuments: true
|
||||
atom.deserializers.add(this)
|
||||
constructor: ->
|
||||
super
|
||||
@deserializing = @state?
|
||||
|
||||
@deserialize: (state) ->
|
||||
new this(state)
|
||||
created: ->
|
||||
if @deserializing
|
||||
@deserializing = false
|
||||
return
|
||||
|
||||
constructor: (optionsOrState) ->
|
||||
if optionsOrState instanceof telepath.Document
|
||||
@state = optionsOrState
|
||||
|
||||
# TODO: This needs to be made async, but should wait until the new Telepath changes land
|
||||
@buffer = atom.project.bufferForPathSync(optionsOrState.get('bufferPath'))
|
||||
if @buffer? and @buffer.isAlive()
|
||||
@bufferPath = @buffer.getPath()
|
||||
else
|
||||
{ @buffer, tabLength } = optionsOrState
|
||||
@state = atom.site.createDocument
|
||||
deserializer: @constructor.name
|
||||
bufferPath: @buffer.getPath()
|
||||
tabLength: tabLength ? atom.config.get('editor.tabLength') ? 2
|
||||
@buffer = @project.bufferForPathSync(@bufferPath)
|
||||
|
||||
@subscribe atom.syntax, 'grammar-added grammar-updated', (grammar) =>
|
||||
if grammar.injectionSelector?
|
||||
@@ -48,15 +43,25 @@ class TokenizedBuffer
|
||||
|
||||
@on 'grammar-changed grammar-updated', => @resetTokenizedLines()
|
||||
@subscribe @buffer, "changed", (e) => @handleBufferChange(e)
|
||||
@subscribe @buffer, "path-changed", => @state.set('bufferPath', @buffer.getPath())
|
||||
@subscribe @buffer, "path-changed", => @bufferPath = @buffer.getPath()
|
||||
|
||||
@subscribe @$tabLength.changes.onValue (tabLength) =>
|
||||
lastRow = @buffer.getLastRow()
|
||||
@tokenizedLines = @buildPlaceholderTokenizedLinesForRows(0, lastRow)
|
||||
@invalidateRow(0)
|
||||
@emit "changed", { start: 0, end: lastRow, delta: 0 }
|
||||
|
||||
@subscribe atom.config.observe 'editor.tabLength', callNow: false, =>
|
||||
@setTabLength(atom.config.getPositiveInt('editor.tabLength'))
|
||||
|
||||
@reloadGrammar()
|
||||
|
||||
serialize: -> @state.clone()
|
||||
getState: -> @state
|
||||
# TODO: Remove when everything is a telepath model
|
||||
destroy: ->
|
||||
@destroyed()
|
||||
|
||||
destroyed: ->
|
||||
@unsubscribe()
|
||||
|
||||
setGrammar: (grammar, score) ->
|
||||
return if grammar is @grammar
|
||||
@@ -90,24 +95,19 @@ class TokenizedBuffer
|
||||
#
|
||||
# Returns a {Number}.
|
||||
getTabLength: ->
|
||||
@state.get('tabLength')
|
||||
@tabLength
|
||||
|
||||
# Specifies the tab length.
|
||||
#
|
||||
# tabLength - A {Number} that defines the new tab length.
|
||||
setTabLength: (tabLength) ->
|
||||
@state.set('tabLength', tabLength)
|
||||
lastRow = @buffer.getLastRow()
|
||||
@tokenizedLines = @buildPlaceholderTokenizedLinesForRows(0, lastRow)
|
||||
@invalidateRow(0)
|
||||
@emit "changed", { start: 0, end: lastRow, delta: 0 }
|
||||
setTabLength: (@tabLength) ->
|
||||
|
||||
tokenizeInBackground: ->
|
||||
return if not @visible or @pendingChunk or @destroyed
|
||||
return if not @visible or @pendingChunk or not @isAlive()
|
||||
@pendingChunk = true
|
||||
_.defer =>
|
||||
@pendingChunk = false
|
||||
@tokenizeNextChunk() unless @destroyed
|
||||
@tokenizeNextChunk() if @isAlive() and @buffer.isAlive()
|
||||
|
||||
tokenizeNextChunk: ->
|
||||
rowsRemaining = @chunkSize
|
||||
@@ -251,10 +251,6 @@ class TokenizedBuffer
|
||||
endColumn = tokenizedLine.bufferColumnForToken(lastToken) + lastToken.bufferDelta
|
||||
new Range([position.row, startColumn], [position.row, endColumn])
|
||||
|
||||
destroy: ->
|
||||
@unsubscribe()
|
||||
@destroyed = true
|
||||
|
||||
iterateTokensInBufferRange: (bufferRange, iterator) ->
|
||||
bufferRange = Range.fromObject(bufferRange)
|
||||
{ start, end } = bufferRange
|
||||
|
||||
@@ -10,4 +10,5 @@ Atom = require './atom'
|
||||
window.atom = new Atom()
|
||||
atom.setUpEnvironment('editor')
|
||||
atom.startEditorWindow()
|
||||
console.log "Window load time: #{Date.now() - startTime}ms"
|
||||
window.atom.loadTime = Date.now() - startTime
|
||||
console.log "Window load time: #{atom.getWindowLoadTime()}ms"
|
||||
|
||||
@@ -118,8 +118,6 @@ class WorkspaceView extends View
|
||||
@command 'window:save-all', => @saveAll()
|
||||
@command 'window:toggle-invisibles', =>
|
||||
atom.config.toggle("editor.showInvisibles")
|
||||
@command 'window:toggle-ignored-files', =>
|
||||
atom.config.toggle("core.hideGitIgnoredFiles")
|
||||
|
||||
@command 'window:toggle-auto-indent', =>
|
||||
atom.config.toggle("editor.autoIndent")
|
||||
|
||||
2
vendor/apm
vendored
2
vendor/apm
vendored
Submodule vendor/apm updated: 5aa7984e15...007cf26433
Reference in New Issue
Block a user