Commit Graph

51 Commits

Author SHA1 Message Date
Allan Odgaard
34bf85d8d1 Remove whitespace when shifting text left
Previously shifting text left/right would ignore blank lines (as noted in issue #419).

When shifting left though it does make sense to delete whitespace, especially as the same code is used to re-indent when pasting.

Fixes #810.
2013-03-13 12:38:12 +01:00
Allan Odgaard
0075b46c82 Introduce zeroIndentPattern
This will give the matched lines zero indent but without affecting the following lines.

Probably the only use-case for this is C preprocessor directives.
2013-03-13 12:38:12 +01:00
Allan Odgaard
d16f3bcc1e Use per-line indent patterns when estimating indent
This solves the problem where we need to estimate the current line’s indent, but the lines above it is a multi-line block comment. Previously we would fetch indent patterns based on the current scope, then find the first line above caret, for which the patterns can be used to estimate the indent. The problem is that the commented lines without comment markers would be treated as code, and used for the indent.

With the new approach, we can set different patterns for ‘comment.block’ (the C bundle already does this), which basically ignore all the lines, which will cause TextMate to use the code above the comment to estimate indent.

This commit closes textmate/c.tmbundle#3 and also closes textmate/php.tmbundle#24.
2013-03-13 12:38:12 +01:00
Allan Odgaard
02f32977f2 Introduce Replace [and Find] in find protocol
Previously there was a single replace action and the options would indicate if it was a “replace all”, this mimics the “find” (which can be a “find all”) but since single match replacement is somewhat different than a “replace all”, as the former may need to know the captures from a previous find action, it makes sense to factor out these things as different actions.
2013-03-07 16:21:47 +01:00
Allan Odgaard
81f8cc4e29 Use current indent for lines matching the “ignore” pattern
This is only when explicitly asking TextMate to indent the current line / selection.

Previously these lines would remain at their current indent, this is useful for preprocessor commands, but majority of ignored lines should use current indent. It might be useful to introduce a new pattern for “zero indent” lines.
2013-02-18 15:38:25 +01:00
Allan Odgaard
ddc85708f8 Allow disabling auto-indent for snippets
Snippets are normally inserted with indent matching that of the caret. This isn’t always desired, which is why TM 1.x allowed this feature to be disabled. This is now also supported for 2.0.

Closes #387.
2013-02-08 13:55:10 +01:00
Allan Odgaard
44b0da80b1 Look at entire line when auto-pairing characters
When inserting paired characters where the pair consists of the same two characters, we look if the line is already balanced, and if so, insert a pair, and if not, only insert a single character. Previously we only looked at what was left of the caret, though TextMate 1.x looked at the full line, which we now also do in 2.0.

Closes #508.
2013-02-08 13:55:10 +01:00
Allan Odgaard
b139ac5097 Change push_back → emplace_back (C++11)
This is mainly motivated by readability, so I only did a few select replacements.
2013-02-08 11:20:35 +01:00
Allan Odgaard
ebc4fa26af Use regexp::match_t::operator[]
Also bypass NSString/c_str() by using std::stod().
2013-02-08 11:20:35 +01:00
Allan Odgaard
9eb4044fdb Switch to simpler regexp::search 2013-02-08 11:20:35 +01:00
Allan Odgaard
e75e7ec8e5 Change text::format → std::to_string (C++11) 2013-02-08 11:20:34 +01:00
Allan Odgaard
18998cba53 Drop snippets on undo
This isn’t ideal but better than a potential crash (following the next edit). A better solution will have to wait to a larger refactoring (which should also consider multiple editors working on the same buffer).

Closes #186.
2013-01-29 15:31:10 +01:00
Allan Odgaard
901bf378c0 Fix build error (clang-421.0.57) 2013-01-28 22:08:17 +01:00
Allan Odgaard
36e612930d Don’t setup variables in test proxy 2013-01-20 12:49:34 +01:00
Allan Odgaard
6c05cae8ed Use std::inserter helper function 2013-01-20 12:49:32 +01:00
Allan Odgaard
759b7d1ae5 Introduce ui_proxy_t::show_browser 2013-01-10 06:46:44 +01:00
Allan Odgaard
a7a633f993 Remove procedural API for load/save of session
Since everything about session is now contained in the DocumentController class there is no need for invoking this from elsewhere and thus no need for the previous indirection.
2013-01-10 06:46:43 +01:00
Allan Odgaard
1a3c9d5db9 Add missing const qualifier 2013-01-08 22:48:07 +01:00
Allan Odgaard
6f1cef364d Support “Select Output” as caret placement
Issue #645.
2012-12-28 02:47:20 +01:00
Michael Sheets
ac8f88b33e Always set the TM_SOFT_TABS variable
Backwards compatibility for commands that expect the variable to always exist or match the NO state, this matches the behavior of 1.x.
2012-12-11 17:52:20 +01:00
Allan Odgaard
6908062ac9 Fix command input with column selections
Discontinuous selections are still not supported for commands — probably the command should be run for each selection.

Issue #524.
2012-10-24 18:19:24 +07:00
Allan Odgaard
494d38df16 Cycle discontinuous selections when using ‘transpose’
It performs a cyclic permutation. If there are only two selections, this is equivalent to swap, but with more discontinuous selections, it is possible to repeat the transpose until the selections are ordered as desired.
2012-09-30 23:06:58 +02:00
Allan Odgaard
bae6270d6c Add indent aware begin/end of line action methods
The methods going to “begin of indented line” will go to the first non-whitespace character on the line, unless the caret is already there or to the left of this character, in which case it will go to the actual beginning of the line.

The “end of indented line” methods work similarly.

If you want [⇪]⌘⇠/⇢ and ⌘⌫/⌦ to use this behavior, you can add the following to your key bindings file:

	"@\UF702"  = "moveToBeginningOfIndentedLine:";
	"$@\UF702" = "moveToBeginningOfIndentedLineAndModifySelection:";
	"@\UF703"  = "moveToEndOfIndentedLine:";
	"$@\UF703" = "moveToEndOfIndentedLineAndModifySelection:";
	"@\U007F"  = "deleteToBeginningOfIndentedLine:";
	"@\UF728"  = "deleteToEndOfIndentedLine:";
2012-09-21 20:29:58 +02:00
Allan Odgaard
a1a5569ae6 Don’t select implicit padding
For example moving the selection often require padding to be inserted, previously this padding would become part of the selection.

This fixes issue #72.
2012-09-21 16:24:43 +02:00
Allan Odgaard
e4ea7834c1 Refactoring 2012-09-21 16:24:43 +02:00
Allan Odgaard
057f07448f Fix “move selection” for east asian scripts
Since it moves one column left/right and east asian scripts have their glyphs count as two columns, it would effectively move half a column, which in practice would be done by inserting a space.

Fixes issue #469.
2012-09-21 16:24:43 +02:00
Allan Odgaard
86461a30b7 Add flag to ignore east asian width 2012-09-21 16:24:42 +02:00
Allan Odgaard
ebab500ba3 Use std::map/set instead of C arrays
These types come with a find() method and avoids having to use helper functions to get the begin/end of the array (for linear search).
2012-09-20 12:22:20 +02:00
Allan Odgaard
017343a7dc TM_SELECTED_TEXT must not exceed ARG_MAX
If the selection exceeds ARG_MAX (256 KB) then we instead set it to a placeholder value.

Previously execve() would fail if given a selection (environment) variable too big.
2012-09-20 12:22:19 +02:00
Allan Odgaard
48616a7ea1 Make document_t::scope private
Ideally should be removed entirely but as document presently does load/save where we need scopes (for import/export commands), we need it internally.
2012-09-18 19:38:01 +02:00
Allan Odgaard
c26e5c2d36 Scope attributes are now given to editor_t
While presently it works the same, it allows us to provide better scope attributes e.g. for untitled documents (which lack SCM attributes).
2012-09-18 17:33:01 +02:00
Allan Odgaard
4ad00f7797 Avoid calling scope in completion functions
Instead we pass the scope as a parameter.
2012-09-18 17:33:00 +02:00
Allan Odgaard
19ef687334 Preserve arguments for recursive call to self 2012-09-18 17:33:00 +02:00
Allan Odgaard
130d0a168d Move check for indent corrections to OakTextView
This makes it easier to introduce a UI setting for the option.
2012-09-18 17:33:00 +02:00
Allan Odgaard
79254cbb6b Add find{Next,Previous}AndModifySelection: action methods
Presently no keys or menu items bound to these.
2012-09-06 23:10:55 +02:00
Jacob Bandes-Storch
e3aa997b06 Use libc++: replace std::tr1 with std 2012-08-28 13:30:20 +02:00
Allan Odgaard
3415d775c5 Use symbolic name for FD_CLOEXEC
Unsure why I was using ‘1’ — perhaps the symbolic name was missing in the older SDK.
2012-08-24 16:52:45 +02:00
Allan Odgaard
80bf684510 Don’t disallow snippet expansion in last placeholder
This was (temporarily) disallowed by previous commit. We do however need to allow it in the last placeholder since that is used for chaining snippets. See issue #182.
2012-08-21 19:43:30 +02:00
Allan Odgaard
40822e87e6 Limit recursive snippet expansion
If caret is at the first position of a place holder then we no longer look for tab expansions, should the user press tab.

This address the issue where a placeholder has optional content and the word to the left of this optional content is a tab trigger. Previously deleting the placeholder text and pressing tab would insert a new snippet, which would generally not be expected.

This closes issue #226.
2012-08-21 19:43:10 +02:00
Allan Odgaard
74085dd53c Don’t mark empty snippet placeholders ‘unanchored’
Ranges can be unanchored which is when they are made (mainly) by a unit selection, for example “select to enclosing braces”. What it means is that if we later use shift + movement actions (to “move” the selection end point) we will always extend it (as we don’t know which of the two end points should be considered the anchor).

Though the unanchored flag has a double role, for snippet placeholders we also set it, when we select the placeholder field, and when user press tab, we ignore tab expansions if there is an unanchored selection. So this disables recursive snippet expansion if the user immediately press tab when reaching a snippet placeholder.

Turns out that when we reach the last field of a snippet, some users want a new snippet expansion.

This fix is not ideal, but by far the easiest, and it achieves the goal.

This closes issue #182.
2012-08-20 15:44:48 +02:00
Allan Odgaard
4c66bfd213 Fix copy to find/replace clipboard with non-standard selections
Previously it would place either the column or discontinuous selection on the find/replace clipboard, which wasn’t useful.

Now it only places the “first” range (of a discontinuous) selection on the clipboard, or first row of a column selection.
2012-08-18 23:56:58 +02:00
Allan Odgaard
a84f597b82 Use wrap column from layout
This closes issue #158.
2012-08-18 23:56:58 +02:00
Allan Odgaard
12d700a8a9 fixup! Fix trailing whitespace in text reformat
We still got the extra (double) newline after the paragraph.
2012-08-18 22:11:10 +02:00
Allan Odgaard
be63bda3e7 Support East Asian Width
There is a bunch of functions that deal with the logical column count and these now all count code points with the “east asian width” (unicode) property set as two columns.

This closes issue #206.
2012-08-18 21:29:05 +02:00
Damon McDougall
36b2e82e3a Fix trailing whitespace in text reformat
On a ^Q text reformat, trailing whitespaces were not removed. Typically
whitespace is typically considered undesirable.
2012-08-18 19:06:14 +02:00
Allan Odgaard
4a22d1af54 Split disableIndentCorrections into two settings
The `disableIndentCorrections` setting now only disables the (aggressive) indent corrections that TextMate does while you type.

There is an additional `indentOnPaste` which you can set to:

1. `simple` — this is the indent behavior which was previously implied when setting `disableIndentCorrections`. It indents the paste to the position of the caret and works well for Python.
2. `disable` — the text is inserted as-is without indenting it.
3. «unset» — indent the paste based on the indent patterns of the current scope.
2012-08-15 22:59:51 +02:00
Allan Odgaard
d8c73a82c8 Pasting on empty line no longer inserts newline
This closes issue #69.
2012-08-15 22:53:47 +02:00
Allan Odgaard
3f00d23de7 Consecutive deletes extend the yank clipboard
This turned out to be a little more involved due to how we need to make a distinction between a forward delete (prepend) and backward delete (append).

Implements issue #118.
2012-08-13 21:30:57 +02:00
Allan Odgaard
4594b08c46 Improve variable names 2012-08-13 21:27:03 +02:00
Nathaniel Tagg
99ab4e6578 Implement ⌃Y for yanking last deletion 2012-08-11 22:41:02 +02:00