diff --git a/Rakefile b/Rakefile index 76c5a0c31..4738d367f 100644 --- a/Rakefile +++ b/Rakefile @@ -28,7 +28,7 @@ end desc "Download node binary" task "update-node" do - `script/update-node v0.10.1` + `script/update-node v0.10.3` end desc "Download debug symbols for CEF" diff --git a/atom.gyp b/atom.gyp index ea825f03c..c586fc011 100644 --- a/atom.gyp +++ b/atom.gyp @@ -175,7 +175,7 @@ # is marked for no PIE (ASLR). 'postbuild_name': 'Make More Helpers', 'action': [ - 'tools/mac/make_more_helpers.sh', + 'script/make_more_helpers.sh', 'Frameworks', 'Atom', ], diff --git a/notes/file-modification b/notes/file-modification deleted file mode 100644 index a3df1c0be..000000000 --- a/notes/file-modification +++ /dev/null @@ -1,18 +0,0 @@ -Buffers - modify - - if dirty alert user (immediately if focused, or on next focus) - - if clean update contents - - remove - - mark file as unsaved (but maintains previous path) - - only unsubscribe from KQueue - - attempt to resubscribe after timeout (because of git weirdness) - - move file - - update path - - move ancestor directory - - update path on focus and save - - recreated after remove (at same path) - - resubscribe on focus or save \ No newline at end of file diff --git a/notes/kyles-little-things.md b/notes/kyles-little-things.md deleted file mode 100644 index 2f8f21efd..000000000 --- a/notes/kyles-little-things.md +++ /dev/null @@ -1,6 +0,0 @@ -## The Little Things™ -I recently switched over to Sublime Text 2 and for the most part it's been pretty awesome. But I've been noticing a lot of little things that I really appreciate in an editor, so I thought I'd note them down. - -1. Indenting soft-wrapped lines http://share.kyleneath.com/captures/_upsell.html.erb-20120127-231402.png -2. Respecting Chrome-like tab behavior (drag between windows/panes, `⌘+Shift+T` to get last closed tab back, `⌘+N` for a new tab in your current pane) -3. Indent markers http://share.kyleneath.com/captures/billing_dependency.rb-20120127-232754.png diff --git a/package.json b/package.json index 1d2e2541e..c691b0b27 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "coffee-cache": "0.1.0", "pegjs": "0.7.0", "async": "0.2.6", - "nak": "git://github.com/kevinsawicki/nak.git", + "nak": "0.2.12", "spellchecker": "0.2.0", "plist": "git://github.com/nathansobo/node-plist.git", "space-pen": "git://github.com/nathansobo/space-pen.git" diff --git a/script/bootstrap b/script/bootstrap index 4db2c1279..a2898082a 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -21,7 +21,7 @@ exit_unless_npm_exists npm install npm --silent NODE_DIR="$HOME/.cefode-gyp" -NODE_VERSION="0.10.1" +NODE_VERSION="0.10.3" NODE_URL="https://gh-contractor-zcbenz.s3.amazonaws.com/cefode2/dist" if [ ! -d "node_modules/node-gyp" ]; then ./node_modules/.bin/npm install node-gyp --silent diff --git a/tools/mac/change_mach_o_flags.py b/script/change_mach_o_flags.py similarity index 100% rename from tools/mac/change_mach_o_flags.py rename to script/change_mach_o_flags.py diff --git a/tools/mac/make_more_helpers.sh b/script/make_more_helpers.sh similarity index 100% rename from tools/mac/make_more_helpers.sh rename to script/make_more_helpers.sh diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 06a0a047c..bd4537617 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -1283,9 +1283,11 @@ describe "EditSession", -> expect(cursor1.getBufferPosition()).toEqual [1, 0] expect(cursor2.getBufferPosition()).toEqual [2, 0] - editSession.backspaceToBeginningOfLine() - expect(buffer.lineForRow(1)).toBe 'ems) {' - expect(cursor1.getBufferPosition()).toEqual [1, 0] + describe "when at the beginning of the line", -> + it "deletes the newline", -> + editSession.setCursorBufferPosition([2]) + editSession.backspaceToBeginningOfLine() + expect(buffer.lineForRow(1)).toBe ' var sort = function(items) { if (items.length <= 1) return items;' describe "when text is selected", -> it "still deletes all text to begginning of the line", -> @@ -2157,3 +2159,40 @@ describe "EditSession", -> expect(buffer.getMarkerCount()).toBeGreaterThan 0 editSession.destroy() expect(buffer.getMarkerCount()).toBe 0 + + describe ".joinLine()", -> + describe "when no text is selected", -> + describe "when the line below isn't empty", -> + it "joins the line below with the current line separated by a space and moves the cursor to the start of line that was moved up", -> + editSession.joinLine() + expect(editSession.lineForBufferRow(0)).toBe 'var quicksort = function () { var sort = function(items) {' + expect(editSession.getCursorBufferPosition()).toEqual [0, 30] + + describe "when the line below is empty", -> + it "deletes the line below and moves the cursor to the end of the line", -> + editSession.setCursorBufferPosition([9]) + editSession.joinLine() + expect(editSession.lineForBufferRow(9)).toBe ' };' + expect(editSession.lineForBufferRow(10)).toBe ' return sort(Array.apply(this, arguments));' + expect(editSession.getCursorBufferPosition()).toEqual [9, 4] + + describe "when the cursor is on the last row", -> + it "does nothing", -> + editSession.setCursorBufferPosition([Infinity, Infinity]) + editSession.joinLine() + expect(editSession.lineForBufferRow(12)).toBe '};' + + describe "when text is selected", -> + describe "when the selection does not span multiple lines", -> + it "joins the line below with the current line separated by a space and retains the selected text", -> + editSession.setSelectedBufferRange([[0, 1], [0, 3]]) + editSession.joinLine() + expect(editSession.lineForBufferRow(0)).toBe 'var quicksort = function () { var sort = function(items) {' + expect(editSession.getSelectedBufferRange()).toEqual [[0, 1], [0, 3]] + + describe "when the selection spans multiple lines", -> + it "joins all selected lines separated by a space and retains the selected text", -> + editSession.setSelectedBufferRange([[9, 3], [12, 1]]) + editSession.joinLine() + expect(editSession.lineForBufferRow(9)).toBe ' }; return sort(Array.apply(this, arguments)); };' + expect(editSession.getSelectedBufferRange()).toEqual [[9, 3], [9, 49]] diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index c72fc5302..a17c914f0 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -778,6 +778,9 @@ class EditSession lowerCase: -> @replaceSelectedText selectWordIfEmpty:true, (text) => text.toLowerCase() + joinLine: -> + @mutateSelectedText (selection) -> selection.joinLine() + expandLastSelectionOverLine: -> @getLastSelection().expandOverLine() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 3a505257e..fa5aeb783 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -157,6 +157,7 @@ class Editor extends View 'editor:move-line-up': @moveLineUp 'editor:move-line-down': @moveLineDown 'editor:duplicate-line': @duplicateLine + 'editor:join-line': @joinLine 'editor:toggle-indent-guide': => config.set('editor.showIndentGuide', !config.get('editor.showIndentGuide')) 'editor:save-debug-snapshot': @saveDebugSnapshot 'editor:toggle-line-numbers': => config.set('editor.showLineNumbers', !config.get('editor.showLineNumbers')) @@ -186,6 +187,7 @@ class Editor extends View moveLineDown: -> @activeEditSession.moveLineDown() setCursorScreenPosition: (position, options) -> @activeEditSession.setCursorScreenPosition(position, options) duplicateLine: -> @activeEditSession.duplicateLine() + joinLine: -> @activeEditSession.joinLine() getCursorScreenPosition: -> @activeEditSession.getCursorScreenPosition() getCursorScreenRow: -> @activeEditSession.getCursorScreenRow() setCursorBufferPosition: (position, options) -> @activeEditSession.setCursorBufferPosition(position, options) diff --git a/src/app/keymaps/editor.cson b/src/app/keymaps/editor.cson index f9675e6c1..52522ce73 100644 --- a/src/app/keymaps/editor.cson +++ b/src/app/keymaps/editor.cson @@ -24,6 +24,7 @@ 'ctrl-meta-up': 'editor:move-line-up' 'ctrl-meta-down': 'editor:move-line-down' 'meta-D': 'editor:duplicate-line' + 'ctrl-J': 'editor:join-line' '.editor.mini': 'enter': 'core:confirm', diff --git a/src/app/selection.coffee b/src/app/selection.coffee index 9be2f7f97..817769281 100644 --- a/src/app/selection.coffee +++ b/src/app/selection.coffee @@ -243,7 +243,10 @@ class Selection @deleteSelectedText() backspaceToBeginningOfLine: -> - @selectToBeginningOfLine() + if @isEmpty() and @cursor.isAtBeginningOfLine() + @selectLeft() + else + @selectToBeginningOfLine() @deleteSelectedText() delete: -> @@ -283,6 +286,31 @@ class Selection end-- @editSession.buffer.deleteRows(start, end) + joinLine: -> + selectedRange = @getBufferRange() + if selectedRange.isEmpty() + return if selectedRange.start.row is @editSession.buffer.getLastRow() + else + joinMarker = @editSession.markBufferRange(selectedRange, invalidationStrategy: 'never') + + rowCount = Math.max(1, selectedRange.getRowCount() - 1) + for row in [0...rowCount] + @cursor.setBufferPosition([selectedRange.start.row]) + @cursor.moveToEndOfLine() + nextRow = selectedRange.start.row + 1 + if nextRow <= @editSession.buffer.getLastRow() and @editSession.buffer.lineLengthForRow(nextRow) > 0 + @insertText(' ') + @cursor.moveToEndOfLine() + @modifySelection => + @cursor.moveRight() + @cursor.moveToFirstCharacterOfLine() + @deleteSelectedText() + + if joinMarker? + newSelectedRange = @editSession.getMarkerBufferRange(joinMarker) + @setBufferRange(newSelectedRange) + @editSession.destroyMarker(joinMarker) + outdentSelectedRows: -> [start, end] = @getBufferRowRange() buffer = @editSession.buffer diff --git a/static/editor.less b/static/editor.less index c9ab251fa..4ac5cb832 100644 --- a/static/editor.less +++ b/static/editor.less @@ -31,12 +31,12 @@ min-width: 1em; box-sizing: border-box; text-align: right; - opacity: 0.6; } .editor .gutter .line-number { padding-right: .5em; padding-left: .5em; + opacity: 0.6; } .editor .gutter .line-numbers {