Merge branch 'master' into bo-grammar-preload

This commit is contained in:
Kevin Sawicki 2014-06-23 17:05:48 -07:00
commit 0a54233ef0
15 changed files with 111 additions and 78 deletions

View File

@ -40,13 +40,15 @@ module.exports = (grunt) ->
mkdir path.dirname(shareDir)
cp shellAppDir, shareDir
# Create Atom.desktop if installation in '/usr/local'
applicationsDir = path.join('/usr','share','applications')
# Create Atom.desktop if installation not in temporary folder
tmpDir = if process.env.TMPDIR? then process.env.TMPDIR else '/tmp'
if installDir.indexOf(tmpDir) isnt 0 and fs.isDirectorySync(applicationsDir)
desktopInstallFile = path.join(installDir,'share','applications','Atom.desktop')
if installDir.indexOf(tmpDir) isnt 0
mkdir path.dirname(desktopInstallFile)
{description} = grunt.file.readJSON('package.json')
installDir = path.join(installDir,'.') # To prevent "Exec=/usr/local//share/atom/atom"
fillTemplate(desktopFile, {description, installDir, iconName})
cp desktopFile, path.join(applicationsDir,'Atom.desktop')
cp desktopFile, desktopInstallFile
# Create relative symbol link for apm.
process.chdir(binDir)

View File

@ -61,6 +61,13 @@ and restart Atom. If Atom now works fine, you can make this setting permanent:
See also https://github.com/atom/atom/issues/2082.
### /usr/bin/env: node: No such file or directory
If you get this notice when attempting to `script/build`, you either do not
have nodejs installed, or node isn't identified as nodejs on your machine.
If it's the latter, entering `sudo ln -s /usr/bin/nodejs /usr/bin/node` into
your terminal may fix the issue.
### Linux build error reports in atom/atom
* Use [this search](https://github.com/atom/atom/search?q=label%3Abuild-error+label%3Alinux&type=Issues)
to get a list of reports about build errors on Linux.

View File

@ -89,22 +89,22 @@
"image-view": "0.35.0",
"keybinding-resolver": "0.18.0",
"link": "0.24.0",
"markdown-preview": "0.83.0",
"markdown-preview": "0.84.0",
"metrics": "0.32.0",
"open-on-github": "0.28.0",
"package-generator": "0.31.0",
"release-notes": "0.32.0",
"settings-view": "0.128.0",
"snippets": "0.46.0",
"snippets": "0.47.0",
"spell-check": "0.38.0",
"status-bar": "0.41.0",
"styleguide": "0.29.0",
"symbols-view": "0.56.0",
"symbols-view": "0.59.0",
"tabs": "0.42.0",
"timecop": "0.19.0",
"timecop": "0.20.0",
"tree-view": "0.104.0",
"update-package-dependencies": "0.6.0",
"welcome": "0.16.0",
"welcome": "0.17.0",
"whitespace": "0.22.0",
"wrap-guide": "0.19.0",
"language-c": "0.21.0",
@ -126,7 +126,7 @@
"language-property-list": "0.7.0",
"language-python": "0.18.0",
"language-ruby": "0.30.0",
"language-ruby-on-rails": "0.14.0",
"language-ruby-on-rails": "0.15.0",
"language-sass": "0.13.0",
"language-shellscript": "0.8.0",
"language-source": "0.7.0",
@ -135,7 +135,7 @@
"language-todo": "0.10.0",
"language-toml": "0.12.0",
"language-xml": "0.15.0",
"language-yaml": "0.7.0"
"language-yaml": "0.10.0"
},
"private": true,
"scripts": {

View File

@ -315,6 +315,16 @@ describe "DisplayBuffer", ->
expect(line0.fold).toBe outerFold
expect(line1.fold).toBeUndefined()
describe "when a fold ends where another fold begins", ->
it "continues to hide the lines inside the second fold", ->
fold2 = displayBuffer.createFold(4, 9)
fold1 = displayBuffer.createFold(0, 4)
displayBuffer.logLines(0, 20)
expect(displayBuffer.lineForRow(0).text).toMatch /^0/
expect(displayBuffer.lineForRow(1).text).toMatch /^10/
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})

View File

@ -462,6 +462,20 @@ describe "EditorComponent", ->
expect(component.lineNumberNodeForScreenRow(9).textContent).toBe "10"
expect(gutterNode.offsetWidth).toBe initialGutterWidth
it "renders the .line-numbers div at the full height of the editor even if it's taller than its content", ->
node.style.height = node.offsetHeight + 100 + 'px'
component.measureScrollView()
nextTick()
expect(node.querySelector('.line-numbers').offsetHeight).toBe node.offsetHeight
describe "when the editor.showLineNumbers config is false", ->
it "doesn't render any line numbers", ->
expect(component.refs.gutter).toBeDefined()
atom.config.set("editor.showLineNumbers", false)
expect(component.refs.gutter).not.toBeDefined()
atom.config.set("editor.showLineNumbers", true)
expect(component.refs.gutter).toBeDefined()
describe "fold decorations", ->
describe "rendering fold decorations", ->
it "adds the foldable class to line numbers when the line is foldable", ->
@ -1771,6 +1785,18 @@ describe "EditorComponent", ->
nextTick()
expect(node.querySelector('.line').textContent).toBe "var quicksort "
describe "legacy editor compatibility", ->
it "triggers the screen-lines-changed event before the editor:display-update event", ->
editor.setSoftWrap(true)
callingOrder = []
editor.on 'screen-lines-changed', -> callingOrder.push 'screen-lines-changed'
wrapperView.on 'editor:display-updated', -> callingOrder.push 'editor:display-updated'
editor.insertText("HELLO! HELLO!\n HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! HELLO! ")
nextTick()
expect(callingOrder).toEqual ['screen-lines-changed', 'editor:display-updated']
buildMouseEvent = (type, properties...) ->
properties = extend({bubbles: true, cancelable: true}, properties...)
event = new MouseEvent(type, properties)

View File

@ -8,12 +8,12 @@ GutterComponent = require './gutter-component'
InputComponent = require './input-component'
CursorsComponent = require './cursors-component'
LinesComponent = require './lines-component'
HighlightsComponent = require './highlights-component'
UnderlayerComponent = require './underlayer-component'
ScrollbarComponent = require './scrollbar-component'
ScrollbarCornerComponent = require './scrollbar-corner-component'
SubscriberMixin = require './subscriber-mixin'
DummyHighlightDecoration = {id: 'dummy', screenRange: new Range(new Point(0, 0), new Point(0, 0)), decorations: [{class: 'dummy'}]}
module.exports =
EditorComponent = React.createClass
displayName: 'EditorComponent'
@ -46,7 +46,7 @@ EditorComponent = React.createClass
scopedCharacterWidthsChangeCount: null
render: ->
{focused, fontSize, lineHeight, fontFamily, showIndentGuide, showInvisibles, visible} = @state
{focused, fontSize, lineHeight, fontFamily, showIndentGuide, showInvisibles, showLineNumbers, visible} = @state
{editor, cursorBlinkPeriod, cursorBlinkResumeDelay} = @props
maxLineNumberDigits = editor.getLineCount().toString().length
invisibles = if showInvisibles then @state.invisibles else {}
@ -81,13 +81,17 @@ EditorComponent = React.createClass
className += ' is-focused' if focused
className += ' has-selection' if hasSelection
div className: className, style: {fontSize, lineHeight, fontFamily}, tabIndex: -1,
GutterComponent {
gutter = null
if showLineNumbers
gutter = GutterComponent {
ref: 'gutter', onMouseDown: @onGutterMouseDown, onWidthChanged: @onGutterWidthChanged,
lineDecorations, defaultCharWidth, editor, renderedRowRange, maxLineNumberDigits,
scrollTop, lineHeightInPixels, @pendingChanges, mouseWheelScreenRow
lineDecorations, defaultCharWidth, editor, renderedRowRange, maxLineNumberDigits, scrollViewHeight,
scrollTop, scrollHeight, lineHeightInPixels, @pendingChanges, mouseWheelScreenRow
}
div className: className, style: {fontSize, lineHeight, fontFamily}, tabIndex: -1,
gutter
div ref: 'scrollView', className: 'scroll-view', onMouseDown: @onMouseDown,
InputComponent
ref: 'input'
@ -105,14 +109,7 @@ EditorComponent = React.createClass
editor, lineHeightInPixels, defaultCharWidth, lineDecorations, highlightDecorations,
showIndentGuide, renderedRowRange, @pendingChanges, scrollTop, scrollLeft,
@scrollingVertically, scrollHeight, scrollWidth, mouseWheelScreenRow, invisibles,
visible, scrollViewHeight
}
HighlightsComponent {
editor, scrollTop, scrollLeft, scrollHeight, scrollWidth, highlightDecorations, lineHeightInPixels,
defaultCharWidth, @scopedCharacterWidthsChangeCount
}
UnderlayerComponent {
scrollTop, scrollLeft, scrollHeight, scrollWidth
visible, scrollViewHeight, @scopedCharacterWidthsChangeCount
}
ScrollbarComponent
@ -278,6 +275,12 @@ EditorComponent = React.createClass
if editor.decorationMatchesType(decoration, 'highlight')
filteredDecorations[markerId] ?= {id: markerId, screenRange: marker.getScreenRange(), decorations: []}
filteredDecorations[markerId].decorations.push decoration
# At least in Chromium 31, removing the last highlight causes a rendering
# artifact where chunks of the lines disappear, so we always leave this
# dummy highlight in place to prevent that.
filteredDecorations['dummy'] = DummyHighlightDecoration
filteredDecorations
observeEditor: ->
@ -451,6 +454,7 @@ EditorComponent = React.createClass
@subscribe atom.config.observe 'editor.showIndentGuide', @setShowIndentGuide
@subscribe atom.config.observe 'editor.invisibles', @setInvisibles
@subscribe atom.config.observe 'editor.showInvisibles', @setShowInvisibles
@subscribe atom.config.observe 'editor.showLineNumbers', @setShowLineNumbers
@subscribe atom.config.observe 'editor.scrollSensitivity', @setScrollSensitivity
onFocus: ->
@ -541,7 +545,7 @@ EditorComponent = React.createClass
return unless event.button is 0 # only handle the left mouse button
{editor} = @props
{detail, shiftKey, metaKey} = event
{detail, shiftKey, metaKey, ctrlKey} = event
screenPosition = @screenPositionForMouseEvent(event)
if event.target?.classList.contains('fold-marker')
@ -551,7 +555,7 @@ EditorComponent = React.createClass
if shiftKey
editor.selectToScreenPosition(screenPosition)
else if metaKey
else if metaKey or (ctrlKey and process.platform isnt 'darwin')
editor.addCursorAtScreenPosition(screenPosition)
else
editor.setCursorScreenPosition(screenPosition)
@ -836,6 +840,9 @@ EditorComponent = React.createClass
setShowInvisibles: (showInvisibles) ->
@setState({showInvisibles})
setShowLineNumbers: (showLineNumbers) ->
@setState({showLineNumbers})
setScrollSensitivity: (scrollSensitivity) ->
if scrollSensitivity = parseInt(scrollSensitivity)
@scrollSensitivity = Math.abs(scrollSensitivity) / 100

View File

@ -443,8 +443,7 @@ class Editor extends Model
getText: -> @buffer.getText()
# Public: Replaces the entire contents of the buffer with the given {String}.
setText: (text) ->
@buffer.setText(text)
setText: (text) -> @buffer.setText(text)
# Get the text in the given {Range}.
#

View File

@ -35,6 +35,11 @@ class Fold
# Returns a {Range}.
getBufferRange: ({includeNewline}={}) ->
range = @marker.getRange()
if range.end.row > range.start.row and nextFold = @displayBuffer.largestFoldStartingAtBufferRow(range.end.row)
nextRange = nextFold.getBufferRange()
range = new Range(range.start, nextRange.end)
if includeNewline
range = range.copy()
range.end.row++

View File

@ -15,10 +15,13 @@ GutterComponent = React.createClass
measuredWidth: null
render: ->
{scrollTop, onMouseDown} = @props
{scrollHeight, scrollViewHeight, scrollTop, onMouseDown} = @props
div className: 'gutter', onClick: @onClick, onMouseDown: onMouseDown,
div className: 'line-numbers', ref: 'lineNumbers', style:
# The line-numbers div must have the 'editor-colors' class so it has an
# opaque background to avoid sub-pixel anti-aliasing problems on the GPU
div className: 'gutter line-numbers editor-colors', ref: 'lineNumbers', style:
height: Math.max(scrollHeight, scrollViewHeight)
WebkitTransform: "translate3d(0px, #{-scrollTop}px, 0px)"
componentWillMount: ->
@ -35,7 +38,8 @@ GutterComponent = React.createClass
# visible row range.
shouldComponentUpdate: (newProps) ->
return true unless isEqualForProperties(newProps, @props,
'renderedRowRange', 'scrollTop', 'lineHeightInPixels', 'mouseWheelScreenRow', 'lineDecorations'
'renderedRowRange', 'scrollTop', 'lineHeightInPixels', 'mouseWheelScreenRow', 'lineDecorations',
'scrollViewHeight'
)
{renderedRowRange, pendingChanges, lineDecorations} = newProps

View File

@ -8,17 +8,9 @@ HighlightsComponent = React.createClass
displayName: 'HighlightsComponent'
render: ->
if @isMounted()
{scrollTop, scrollLeft, scrollHeight, scrollWidth} = @props
style =
height: scrollHeight
width: scrollWidth
WebkitTransform: "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)"
div {className: 'highlights', style},
div className: 'highlights',
@renderHighlights() if @isMounted()
renderHighlights: ->
{editor, highlightDecorations, lineHeightInPixels} = @props
@ -30,7 +22,4 @@ HighlightsComponent = React.createClass
highlightComponents
shouldComponentUpdate: (newProps) ->
not isEqualForProperties(newProps, @props,
'scrollTop', 'scrollLeft', 'highlightDecorations', 'lineHeightInPixels',
'defaultCharWidth', 'scopedCharacterWidthsChangeCount'
)
not isEqualForProperties(newProps, @props, 'highlightDecorations', 'lineHeightInPixels', 'defaultCharWidth', 'scopedCharacterWidthsChangeCount')

View File

@ -4,6 +4,8 @@ React = require 'react-atom-fork'
{debounce, isEqual, isEqualForProperties, multiplyString, toArray} = require 'underscore-plus'
{$$} = require 'space-pen'
HighlightsComponent = require './highlights-component'
DummyLineNode = $$(-> @div className: 'line', style: 'position: absolute; visibility: hidden;', => @span 'x')[0]
AcceptFilter = {acceptNode: -> NodeFilter.FILTER_ACCEPT}
WrapperDiv = document.createElement('div')
@ -15,13 +17,16 @@ LinesComponent = React.createClass
render: ->
if @isMounted()
{editor, highlightDecorations, scrollTop, scrollLeft, scrollHeight, scrollWidth} = @props
{lineHeightInPixels, defaultCharWidth, scrollViewHeight} = @props
{lineHeightInPixels, defaultCharWidth, scrollViewHeight, scopedCharacterWidthsChangeCount} = @props
style =
height: Math.max(scrollHeight, scrollViewHeight)
width: scrollWidth
WebkitTransform: "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)"
div {className: 'lines', style}
# The lines div must have the 'editor-colors' class so it has an opaque
# background to avoid sub-pixel anti-aliasing problems on the GPU
div {className: 'lines editor-colors', style},
HighlightsComponent({editor, highlightDecorations, lineHeightInPixels, defaultCharWidth, scopedCharacterWidthsChangeCount})
componentWillMount: ->
@measuredLines = new WeakSet
@ -34,7 +39,7 @@ LinesComponent = React.createClass
return true unless isEqualForProperties(newProps, @props,
'renderedRowRange', 'lineDecorations', 'highlightDecorations', 'lineHeightInPixels', 'defaultCharWidth',
'scrollTop', 'scrollLeft', 'showIndentGuide', 'scrollingVertically', 'invisibles', 'visible',
'scrollViewHeight', 'mouseWheelScreenRow'
'scrollViewHeight', 'mouseWheelScreenRow', 'scopedCharacterWidthsChangeCount'
)
{renderedRowRange, pendingChanges} = newProps

View File

@ -34,7 +34,7 @@ class ReactEditorView extends View
node = @component.getDOMNode()
@scrollView = $(node).find('.scroll-view')
@underlayer = $(node).find('.underlayer')
@underlayer = $(node).find('.highlights').addClass('underlayer')
@overlayer = $(node).find('.lines').addClass('overlayer')
@hiddenInput = $(node).find('.hidden-input')

View File

@ -2,8 +2,8 @@ _ = require 'underscore-plus'
textUtils = require './text-utils'
WhitespaceRegexesByTabLength = {}
LeadingWhitespaceRegex = /^[ ]+/
TrailingWhitespaceRegex = /[ ]+$/
LeadingSpaceRegex = /^[ ]+/
TrailingSpaceRegex = /[ ]+$/
EscapeRegex = /[&"'<>]/g
CharacterRegex = /./g
StartCharacterRegex = /^./
@ -151,7 +151,7 @@ class Token
leadingHtml = ''
trailingHtml = ''
if @hasLeadingWhitespace and match = LeadingWhitespaceRegex.exec(@value)
if @hasLeadingWhitespace and match = LeadingSpaceRegex.exec(@value)
classes = 'leading-whitespace'
classes += ' indent-guide' if hasIndentGuide
classes += ' invisible-character' if invisibles.space
@ -161,7 +161,7 @@ class Token
startIndex = match[0].length
if @hasTrailingWhitespace and match = TrailingWhitespaceRegex.exec(@value)
if @hasTrailingWhitespace and match = TrailingSpaceRegex.exec(@value)
tokenIsOnlyWhitespace = match[0].length is @value.length
classes = 'trailing-whitespace'
classes += ' indent-guide' if hasIndentGuide and not @hasLeadingWhitespace and tokenIsOnlyWhitespace

View File

@ -1,20 +0,0 @@
React = require 'react-atom-fork'
{div} = require 'reactionary-atom-fork'
{isEqualForProperties} = require 'underscore-plus'
module.exports =
UnderlayerComponent = React.createClass
displayName: 'UnderlayerComponent'
render: ->
if @isMounted()
{scrollTop, scrollLeft, scrollHeight, scrollWidth} = @props
style =
height: scrollHeight
width: scrollWidth
WebkitTransform: "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)"
div {className: 'underlayer', style}
shouldComponentUpdate: (newProps) ->
not isEqualForProperties(@props, newProps, 'scrollTop', 'scrollLeft', 'scrollHeight', 'scrollWidth')

View File

@ -6,14 +6,13 @@
.underlayer {
position: absolute;
top: 0;
bottom: 0;
left: 0;
}
.highlights {
right: 0;
z-index: -2;
}
.lines, .highlights, .underlayer {
.lines {
min-width: 100%;
}