Merge branch 'as-remove-gutter-from-view-registry' into as-tiled-gutter

This commit is contained in:
Antonio Scandurra
2015-06-18 19:58:33 +02:00
11 changed files with 118 additions and 39 deletions

View File

@@ -64,7 +64,7 @@
"space-pen": "3.8.2",
"stacktrace-parser": "0.1.1",
"temp": "0.8.1",
"text-buffer": "6.3.6",
"text-buffer": "6.3.7",
"theorist": "^1.0.2",
"typescript-simple": "1.0.0",
"underscore-plus": "^1.6.6",
@@ -90,7 +90,7 @@
"autocomplete-plus": "2.17.3",
"autocomplete-snippets": "1.7.0",
"autoflow": "0.25.0",
"autosave": "0.20.0",
"autosave": "0.21.0",
"background-tips": "0.25.0",
"bookmarks": "0.35.0",
"bracket-matcher": "0.76.0",
@@ -99,7 +99,7 @@
"dev-live-reload": "0.46.0",
"encoding-selector": "0.20.0",
"exception-reporting": "0.24.0",
"find-and-replace": "0.172.0",
"find-and-replace": "0.173.0",
"fuzzy-finder": "0.87.0",
"git-diff": "0.55.0",
"go-to-line": "0.30.0",
@@ -115,11 +115,11 @@
"package-generator": "0.39.0",
"release-notes": "0.53.0",
"settings-view": "0.208.0",
"snippets": "0.94.0",
"snippets": "0.95.0",
"spell-check": "0.59.0",
"status-bar": "0.74.0",
"styleguide": "0.44.0",
"symbols-view": "0.98.0",
"symbols-view": "0.99.0",
"tabs": "0.81.0",
"timecop": "0.31.0",
"tree-view": "0.172.0",
@@ -150,7 +150,7 @@
"language-python": "0.36.0",
"language-ruby": "0.56.0",
"language-ruby-on-rails": "0.22.0",
"language-sass": "0.38.0",
"language-sass": "0.39.0",
"language-shellscript": "0.15.0",
"language-source": "0.9.0",
"language-sql": "0.16.0",

View File

@@ -1229,6 +1229,11 @@ describe "DisplayBuffer", ->
decoration.destroy()
expect(displayBuffer.decorationForId(decoration.id)).not.toBeDefined()
it "does not leak disposables", ->
disposablesSize = displayBuffer.disposables.disposables.size
decoration.destroy()
expect(displayBuffer.disposables.disposables.size).toBe(disposablesSize - 1)
describe "when a decoration is updated via Decoration::update()", ->
it "emits an 'updated' event containing the new and old params", ->
decoration.onDidChangeProperties updatedSpy = jasmine.createSpy()

View File

@@ -68,6 +68,15 @@ describe "TextEditorComponent", ->
expect(nextAnimationFrame).not.toThrow()
it "doesn't update when an animation frame was requested but the component got destroyed before its delivery", ->
editor.setText("You shouldn't see this update.")
expect(nextAnimationFrame).not.toBe(noAnimationFrame)
component.destroy()
nextAnimationFrame()
expect(component.lineNodeForScreenRow(0).textContent).not.toBe("You shouldn't see this update.")
describe "line rendering", ->
expectTileContainsRow = (tileNode, screenRow, {top}) ->
lineNode = tileNode.querySelector("[data-screen-row='#{screenRow}']")
@@ -1614,11 +1623,28 @@ describe "TextEditorComponent", ->
expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [5, 6]]
describe "when the command key is held down", ->
it "adds a cursor at the nearest screen position", ->
editor.setCursorScreenPosition([3, 4])
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([5, 6]), metaKey: true))
nextAnimationFrame()
expect(editor.getSelectedScreenRanges()).toEqual [[[3, 4], [3, 4]], [[5, 6], [5, 6]]]
describe "the current cursor position and screen position do not match", ->
it "adds a cursor at the nearest screen position", ->
editor.setCursorScreenPosition([3, 4])
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([5, 6]), metaKey: true))
nextAnimationFrame()
expect(editor.getSelectedScreenRanges()).toEqual [[[3, 4], [3, 4]], [[5, 6], [5, 6]]]
describe "when there are multiple cursors, and one of the cursor's screen position is the same as the mouse click screen position", ->
it "removes a cursor at the mouse screen position", ->
editor.setCursorScreenPosition([3, 4])
editor.addCursorAtScreenPosition([5, 2])
editor.addCursorAtScreenPosition([7, 5])
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([3, 4]), metaKey: true))
nextAnimationFrame()
expect(editor.getSelectedScreenRanges()).toEqual [[[5, 2], [5, 2]], [[7, 5], [7, 5]]]
describe "when there is a single cursor and the click occurs at the cursor's screen position", ->
it "neither adds a new cursor nor removes the current cursor", ->
editor.setCursorScreenPosition([3, 4])
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([3, 4]), metaKey: true))
nextAnimationFrame()
expect(editor.getSelectedScreenRanges()).toEqual [[[3, 4], [3, 4]]]
describe "when a non-folded line is double-clicked", ->
describe "when no modifier keys are held down", ->

View File

@@ -916,6 +916,12 @@ describe "TextEditor", ->
editor.setCursorBufferPosition([3, 1])
expect(editor.getCurrentParagraphBufferRange()).toBeUndefined()
describe "getCursorAtScreenPosition(screenPosition)", ->
it "returns the cursor at the given screenPosition", ->
cursor1 = editor.addCursorAtScreenPosition([0, 2])
cursor2 = editor.getCursorAtScreenPosition(cursor1.getScreenPosition())
expect(cursor2).toBe cursor1
describe "::getCursorScreenPositions()", ->
it "returns the cursor positions in the order they were added", ->
editor.foldBufferRow(4)
@@ -935,7 +941,7 @@ describe "TextEditor", ->
it "returns the existing cursor", ->
cursor1 = editor.addCursorAtScreenPosition([0, 2])
cursor2 = editor.addCursorAtScreenPosition([0, 2])
expect(cursor2.marker).toBe cursor1.marker
expect(cursor2).toBe cursor1
describe "addCursorAtBufferPosition(bufferPosition)", ->
describe "when a cursor already exists at the position", ->

View File

@@ -105,7 +105,7 @@ class AtomApplication
app.quit()
return
@windows.splice(@windows.indexOf(window), 1)
@saveState() unless window.isSpec or @quitting
@saveState(true) unless window.isSpec
# Public: Adds the {AtomWindow} to the global window list.
addWindow: (window) ->
@@ -116,14 +116,14 @@ class AtomApplication
unless window.isSpec
focusHandler = => @lastFocusedWindow = window
blurHandler = => @saveState()
blurHandler = => @saveState(false)
window.browserWindow.on 'focus', focusHandler
window.browserWindow.on 'blur', blurHandler
window.browserWindow.once 'closed', =>
@lastFocusedWindow = null if window is @lastFocusedWindow
window.browserWindow.removeListener 'focus', focusHandler
window.browserWindow.removeListener 'blur', blurHandler
window.browserWindow.webContents.once 'did-finish-load', => @saveState()
window.browserWindow.webContents.once 'did-finish-load', => @saveState(false)
# Creates server to listen for additional atom application launches.
#
@@ -186,7 +186,10 @@ class AtomApplication
@on 'application:report-issue', -> require('shell').openExternal('https://github.com/atom/atom/blob/master/CONTRIBUTING.md#submitting-issues')
@on 'application:search-issues', -> require('shell').openExternal('https://github.com/issues?q=+is%3Aissue+user%3Aatom')
@on 'application:install-update', => @autoUpdateManager.install()
@on 'application:install-update', =>
@quitting = true
@autoUpdateManager.install()
@on 'application:check-for-update', => @autoUpdateManager.check()
if process.platform is 'darwin'
@@ -210,7 +213,7 @@ class AtomApplication
@openPathOnEvent('application:open-license', path.join(process.resourcesPath, 'LICENSE.md'))
app.on 'before-quit', =>
@saveState() if @hasEditorWindows()
@saveState(false)
@quitting = true
app.on 'will-quit', =>
@@ -218,7 +221,7 @@ class AtomApplication
@deleteSocketFile()
app.on 'will-exit', =>
@saveState() if @hasEditorWindows()
@saveState(false)
@killAllProcesses()
@deleteSocketFile()
@@ -270,6 +273,9 @@ class AtomApplication
@promptForPath "folder", (selectedPaths) ->
event.sender.send(responseChannel, selectedPaths)
ipc.on 'cancel-window-close', =>
@quitting = false
clipboard = null
ipc.on 'write-text-to-selection-clipboard', (event, selectedText) ->
clipboard ?= require '../safe-clipboard'
@@ -433,16 +439,15 @@ class AtomApplication
console.log("Killing process #{pid} failed: #{error.code ? error.message}")
delete @pidsToOpenWindows[pid]
saveState: ->
saveState: (allowEmpty=false) ->
return if @quitting
states = []
for window in @windows
unless window.isSpec
if loadSettings = window.getLoadSettings()
states.push(initialPaths: loadSettings.initialPaths)
@storageFolder.store('application.json', states)
hasEditorWindows: ->
@windows.some (window) -> not window.isSpec
if states.length > 0 or allowEmpty
@storageFolder.store('application.json', states)
loadState: ->
if (states = @storageFolder.load('application.json'))?.length > 0

View File

@@ -974,7 +974,10 @@ class DisplayBuffer extends Model
decorateMarker: (marker, decorationParams) ->
marker = @getMarker(marker.id)
decoration = new Decoration(marker, this, decorationParams)
@disposables.add decoration.onDidDestroy => @removeDecoration(decoration)
decorationDestroyedDisposable = decoration.onDidDestroy =>
@removeDecoration(decoration)
@disposables.remove(decorationDestroyedDisposable)
@disposables.add(decorationDestroyedDisposable)
@decorationsByMarkerId[marker.id] ?= []
@decorationsByMarkerId[marker.id].push(decoration)
@overlayDecorationsById[decoration.id] = decoration if decoration.isType('overlay')

View File

@@ -56,7 +56,7 @@ class LanguageMode
allBlank = true
allBlankOrCommented = true
for row in [start..end]
for row in [start..end] by 1
line = buffer.lineForRow(row)
blank = line?.match(/^\s*$/)
@@ -66,7 +66,7 @@ class LanguageMode
shouldUncomment = allBlankOrCommented and not allBlank
if shouldUncomment
for row in [start..end]
for row in [start..end] by 1
if match = commentStartRegex.searchSync(buffer.lineForRow(row))
columnStart = match[1].length
columnEnd = columnStart + match[2].length
@@ -79,7 +79,7 @@ class LanguageMode
indentString = @editor.buildIndentString(indent)
tabLength = @editor.getTabLength()
indentRegex = new RegExp("(\t|[ ]{#{tabLength}}){#{Math.floor(indent)}}")
for row in [start..end]
for row in [start..end] by 1
line = buffer.lineForRow(row)
if indentLength = line.match(indentRegex)?[0].length
buffer.insert([row, indentLength], commentStartString)
@@ -89,7 +89,7 @@ class LanguageMode
# Folds all the foldable lines in the buffer.
foldAll: ->
for currentRow in [0..@buffer.getLastRow()]
for currentRow in [0..@buffer.getLastRow()] by 1
[startRow, endRow] = @rowRangeForFoldAtBufferRow(currentRow) ? []
continue unless startRow?
@editor.createFold(startRow, endRow)
@@ -97,7 +97,7 @@ class LanguageMode
# Unfolds all the foldable lines in the buffer.
unfoldAll: ->
for row in [@buffer.getLastRow()..0]
for row in [@buffer.getLastRow()..0] by -1
fold.destroy() for fold in @editor.displayBuffer.foldsStartingAtBufferRow(row)
return
@@ -106,7 +106,7 @@ class LanguageMode
# indentLevel - A {Number} indicating indentLevel; 0 based.
foldAllAtIndentLevel: (indentLevel) ->
@unfoldAll()
for currentRow in [0..@buffer.getLastRow()]
for currentRow in [0..@buffer.getLastRow()] by 1
[startRow, endRow] = @rowRangeForFoldAtBufferRow(currentRow) ? []
continue unless startRow?
@@ -121,7 +121,7 @@ class LanguageMode
#
# Returns the new {Fold}.
foldBufferRow: (bufferRow) ->
for currentRow in [bufferRow..0]
for currentRow in [bufferRow..0] by -1
[startRow, endRow] = @rowRangeForFoldAtBufferRow(currentRow) ? []
continue unless startRow? and startRow <= bufferRow <= endRow
fold = @editor.displayBuffer.largestFoldStartingAtBufferRow(startRow)
@@ -145,13 +145,13 @@ class LanguageMode
endRow = bufferRow
if bufferRow > 0
for currentRow in [bufferRow-1..0]
for currentRow in [bufferRow-1..0] by -1
break if @buffer.isRowBlank(currentRow)
break unless @editor.displayBuffer.tokenizedBuffer.tokenizedLineForRow(currentRow).isComment()
startRow = currentRow
if bufferRow < @buffer.getLastRow()
for currentRow in [bufferRow+1..@buffer.getLastRow()]
for currentRow in [bufferRow+1..@buffer.getLastRow()] by 1
break if @buffer.isRowBlank(currentRow)
break unless @editor.displayBuffer.tokenizedBuffer.tokenizedLineForRow(currentRow).isComment()
endRow = currentRow
@@ -163,7 +163,7 @@ class LanguageMode
startIndentLevel = @editor.indentationForBufferRow(bufferRow)
scopeDescriptor = @editor.scopeDescriptorForBufferPosition([bufferRow, 0])
for row in [(bufferRow + 1)..@editor.getLastBufferRow()]
for row in [(bufferRow + 1)..@editor.getLastBufferRow()] by 1
continue if @editor.isBufferRowBlank(row)
indentation = @editor.indentationForBufferRow(row)
if indentation <= startIndentLevel
@@ -272,7 +272,7 @@ class LanguageMode
#
# Returns a {Number} of the indent level of the block of lines.
minIndentLevelForRowRange: (startRow, endRow) ->
indents = (@editor.indentationForBufferRow(row) for row in [startRow..endRow] when not @editor.isBufferRowBlank(row))
indents = (@editor.indentationForBufferRow(row) for row in [startRow..endRow] by 1 when not @editor.isBufferRowBlank(row))
indents = [0] unless indents.length
Math.min(indents...)
@@ -281,7 +281,7 @@ class LanguageMode
# startRow - The row {Number} to start at
# endRow - The row {Number} to end at
autoIndentBufferRows: (startRow, endRow) ->
@autoIndentBufferRow(row) for row in [startRow..endRow]
@autoIndentBufferRow(row) for row in [startRow..endRow] by 1
return
# Given a buffer row, this indents it.

View File

@@ -195,7 +195,7 @@ class TextEditorComponent
@updateRequested = true
atom.views.updateDocument =>
@updateRequested = false
@updateSync() if @editor.isAlive()
@updateSync() if @canUpdate()
atom.views.readDocument(@readAfterUpdateSync)
canUpdate: ->
@@ -392,7 +392,11 @@ class TextEditorComponent
if shiftKey
@editor.selectToScreenPosition(screenPosition)
else if metaKey or (ctrlKey and process.platform isnt 'darwin')
@editor.addCursorAtScreenPosition(screenPosition)
cursorAtScreenPosition = @editor.getCursorAtScreenPosition(screenPosition)
if cursorAtScreenPosition and @editor.hasMultipleCursors()
cursorAtScreenPosition.destroy()
else
@editor.addCursorAtScreenPosition(screenPosition)
else
@editor.setCursorScreenPosition(screenPosition)
when 2

View File

@@ -1565,6 +1565,16 @@ class TextEditor extends Model
setCursorBufferPosition: (position, options) ->
@moveCursors (cursor) -> cursor.setBufferPosition(position, options)
# Essential: Get a {Cursor} at given screen coordinates {Point}
#
# * `position` A {Point} or {Array} of `[row, column]`
#
# Returns the first matched {Cursor} or undefined
getCursorAtScreenPosition: (position) ->
for cursor in @cursors
return cursor if cursor.getScreenPosition().isEqual(position)
undefined
# Essential: Get the position of the most recently added cursor in screen
# coordinates.
#

View File

@@ -64,7 +64,10 @@ class WindowEventHandler
atom.storeDefaultWindowDimensions()
atom.storeWindowDimensions()
atom.unloadEditorWindow() if confirmed
if confirmed
atom.unloadEditorWindow()
else
ipc.send('cancel-window-close')
confirmed

View File

@@ -71,3 +71,20 @@ atom-pane-container {
}
}
}
// Windows doesn't have row- and col-resize cursors
.platform-win32 {
atom-pane-container {
atom-pane-axis.vertical {
& > atom-pane-resize-handle {
cursor: ns-resize;
}
}
atom-pane-axis.horizontal {
& > atom-pane-resize-handle {
cursor: ew-resize;
}
}
}
}