Commit Graph

137 Commits

Author SHA1 Message Date
Mutwin Kraus
2445829f83 Specs for moveCursorToBeginningOfNextWord 2013-04-08 14:15:25 +02:00
Nathan Sobo
763729d08d 🏇 Use buffer ranges to see if selections intersect 2013-04-05 14:52:36 -06:00
Nathan Sobo
abc5ed5190 Add editor:add-selection-above command 2013-04-05 14:52:35 -06:00
Nathan Sobo
bd58834e7d Merge goal ranges when merging selections 2013-04-05 14:17:21 -06:00
Nathan Sobo
be009e87c2 Skip empty lines when adding selections below empty selections
Unless the selection's column is 0
2013-04-05 14:17:21 -06:00
Nathan Sobo
393cba4d42 Don't skip shorter lines when the adding empty selection below 2013-04-05 14:17:21 -06:00
Nathan Sobo
131df22c11 Skip lines that are too-short when adding non-empty selection below 2013-04-05 14:17:21 -06:00
Nathan Sobo
f22461e5e8 Clear goal range when selection is modified
Just like the cursor clears its goal column when it is moved in any
way other than vertically, the selection clears its goal range (the
range it will attempt to use when adding a selection below) when it
is changed in any way.
2013-04-05 14:17:20 -06:00
Nathan Sobo
34019951d3 💄 2013-04-05 14:17:20 -06:00
Nathan Sobo
af923cca9b Preserve original selection's range when adding selection's below
Just like the cursor tries to stay in its "goal column" when moving
vertically, here we try to keep the same selection even when adding
across shorter lines.
2013-04-05 14:17:20 -06:00
Nathan Sobo
26e53584c1 Add 'editor:add-selection-below' command
It still needs work, but the basic idea is for every selection to
add another another selection over the same column range of the line
below.
2013-04-05 14:17:20 -06:00
Kevin Sawicki
e442dfff11 Support joining editor lines with ctrl-J
This can be used with or without a selection to join one
or more lines with the line below it separated by a space.

Refs #134
2013-04-04 11:07:59 -07:00
Kevin Sawicki
9773751e79 Delete left when meta-backspacing at start of line
Previously EditSession.backspaceToBeginningOfLine() would do nothing
if at the beginning of the line.

Now it selects left and does a delete so it can be used to delete
multiple lines continuously without having to move the cursor.

Refs #134
2013-04-04 09:25:35 -07:00
Kevin Sawicki
f8ffe1c408 Only delete to end row when greater than start row
Closes #442
2013-03-21 17:07:36 -07:00
Corey Johnson & Kevin Sawicki
94099358f3 Inserting whitespace never auto-outdents
Closes #340

Shout out to @nathansobo
2013-03-05 10:19:24 -08:00
Corey Johnson & Nathan Sobo
da59459197 Autoscroll the last cursor when it inserts text
Normally, we don't autoscroll to a cursor when the buffer changes. But
this is a change caused by the cursor itself, so it makes sense to
keep it in view.
2013-02-14 13:21:39 -07:00
Nathan Sobo
0bd98bf8f8 Do a better job cleaning up after Editors and EditSessions
- EditSessions destroy their Selections when they are destroyed
- Editors destroy their EditSessions when they are destroyed
- Editors unsubscribe from the document and window when they are
  removed from the DOM.
- When an EditSession is destroyed via any code path, the Editor with
  that EditSession removes it.
- Selections no longer trigger 'destroyed' events if their parent
  EditSession has already been destroyed.

These are all really intertwined, so I'm doing them as one commit
since that was the only way to keep the specs green.
2013-02-06 16:54:19 -07:00
Nathan Sobo
1d30605f7f Convert selection and cursor fully over to markers. 2013-02-05 13:39:00 -07:00
Nathan Sobo
afe0a6570a Reduce observation to single observeMarker method on display buffer
It will call the observer callbacks with the buffer and screen positions
of the head and tell each time any of these values is changed.
2013-02-04 21:24:06 -07:00
Nathan Sobo
80b39ae263 Replace mentions of 'anchor' with 'tail' in selection and its spec 2013-02-02 16:44:13 -07:00
Nathan Sobo
cb6de5b2a4 Honor autoscroll option when setting a selection's buffer range
If we pass an explicit autoscroll option when selection, we don't want
to autoscroll the cursor. If the option is true, we'll autoscroll to
the middle of the selection. If the option is false, we don't want any
autoscrolling, including to the cursor. The cursor should only autoscroll
when the option is undefined.
2013-02-02 15:17:24 -07:00
Nathan Sobo
4a191586db Ensure we don't try to draw a destroyed selection on editor refresh
Destroying the cursor will cause a redraw, which causes a problem when
we execute it synchronously in specs because destroying the cursor also
destroys the marker associated with the selection. Here we remove the
selection first to avoid this problem.
2013-02-02 15:10:01 -07:00
Nathan Sobo
1bbb954239 EditSession specs passing after converting Selection to use markers
Still a bit of a mess though...
2013-01-31 18:26:29 -07:00
Nathan Sobo
113a8fa279 Merge remote-tracking branch 'origin/dev' into better-anchors
Conflicts:
	src/app/cursor.coffee
	src/app/editor.coffee
2013-01-30 12:59:04 -07:00
Corey Johnson
8973a66cfe selection.selectWord will consider whitespace a word 2013-01-29 16:57:22 -08:00
Nathan Sobo
2380fa3445 Handle 'autoscroll' entirely in Cursor instead of in Anchor
This commit makes autoscroll a 3-valued property on the cursor. If it
is set to true or false, that setting will stick until the cursor's
next visual update. That means we can explicitly move the cursor with
autoscroll set to false, but also still autoscroll by default when the
cursor's anchor moves on its own.
2013-01-29 12:11:43 -07:00
Corey Johnson & Nathan Sobo
c13b45df99 Hard tabs in snippets are translated to soft-tabs if necessary 2013-01-28 16:36:15 -07:00
Andy Delcambre
759fe2dd5b Bind meta-= to autoindent currently selected rows
Closes #142
2013-01-18 11:33:20 -08:00
Corey Johnson
f5ee676e5e Pass autoIndent as an option flag
Instead of querying EditSession for autoIndenting
2013-01-09 15:24:04 -08:00
Nathan Sobo
46331ded03 Merge remote-tracking branch 'origin/command-extensions' into dev
Conflicts:
	spec/app/editor-spec.coffee
	spec/app/root-view-spec.coffee
	src/app/editor.coffee
	src/extensions/strip-trailing-whitespace.coffee
2013-01-09 14:18:10 -07:00
Nathan Sobo
0a08d03c68 Rename Buffer, TokenizedBuffer, and Selection events 2013-01-04 13:59:11 -07:00
Nathan Sobo
f4f3002e6d Rename Cursor and CursorView events to passive-voice scheme
Any events emitted from DOM nodes should be prefixed with an identifier
for the node that emits them. This eliminates the possibility of ambiguity
when the events bubble up the DOM away from their emitter.
2013-01-02 13:48:11 -07:00
Jon Rohan
92a9831201 writing spec for .backspaceToBeginningOfLine() 2012-12-28 17:24:57 -08:00
Jon Rohan
006a6d958d Adding meta-backspace which will backspace from cursor to the beginning of line 2012-12-28 16:58:22 -08:00
Corey Johnson & Nathan Sobo
de5bd91055 Paste indent normalization works with on lines w/ mixed indentation
Normalizing the indent no longer explodes when pasting on a line that has mixed tabs and spaces when the edit session is using hard tabs.
2012-12-06 11:59:23 -07:00
Corey Johnson & Nathan Sobo
be2b9ee100 Store autoscroll state on Selection and Cursor models 2012-11-30 12:08:41 -07:00
Corey Johnson & Nathan Sobo
f9c7c08641 Selected results of a find operation are centered in the viewport 2012-11-29 18:52:34 -07:00
Corey Johnson & Nathan Sobo
7eb1f14f05 Don't need to assign retainSelection on the SelectionView anymore 2012-11-29 17:46:58 -07:00
Nathan Sobo
833ccb30ab Pass old and new screen position with Anchor/Cursor move events 2012-11-29 13:39:00 -07:00
Nathan Sobo
91e899456a Rename 'change-screen-position' event to 'moved' on Anchor and Cursor 2012-11-29 13:39:00 -07:00
Corey Johnson & Nathan Sobo
bfb1742285 ctrl-a on an empty line stays on that same line.
Fixes #95
2012-11-19 10:02:31 -08:00
Nathan Sobo
c68d5fac7d Attach precipitating bufferChange to DisplayBuffer change events
The gutter can use this to determine if the change might have altered line numbers, for example if it's inside a fold.
2012-11-14 13:07:42 -07:00
Nathan Sobo
19fedbcffc 💄 2012-11-07 16:24:07 -07:00
Nathan Sobo
19c8a39fc8 Don't autoscroll to bottom of buffer on selectAll 2012-11-07 16:01:10 -07:00
Nathan Sobo
b87d7cd0df Auto-indent skips cursor over leading whitespace before inserting more
This preserves the user's intent to bring the line's total amount of leading whitespace to the desired indent level.
2012-11-05 15:15:00 -07:00
Nathan Sobo
ea87c55db5 Don't clear the selection if it's empty
This avoids emitting selection change events when they aren't really needed. This extra event was causing the highlighted line to be updated when it didn't need to be.
2012-11-01 14:50:51 -06:00
Corey Johnson & Nathan Sobo
b85f3c47eb Rewrite Seleciton.setScreenRange in terms of setBufferRange 2012-10-30 17:07:15 -07:00
Nathan Sobo
007e032224 Expand selection linewise after triple-click (dragging or shift-click) 2012-10-30 14:48:33 -06:00
Corey Johnson & Nathan Sobo
c55332a3a4 WIP: Make selections remember if they are wordwise/linewise
Also always expand from the initial selection after a double/triple click in either direction until directionality of the selection is established.
2012-10-30 13:56:35 -06:00
Nathan Sobo
aa20fbac6d Ignore an empty last line when indenting/outdenting selected lines
This provides more intuitive behavior now that the cursor isn't visible when there's a selection.
2012-10-29 16:16:19 -06:00