Commit Graph

1827 Commits

Author SHA1 Message Date
Allan Odgaard
947b352952 Set pasteboard history search field to fire immediately 2014-03-04 10:40:05 +07:00
Allan Odgaard
a6f6185123 Add NSError info to crash report 2014-03-04 10:24:05 +07:00
Allan Odgaard
c38a1a64af Add to_s overload for NSError 2014-03-04 10:23:01 +07:00
Allan Odgaard
1840f5b7fa Improve utf8::find_safe_end implementation
Previously calling the function with invalid UTF-8 could cause it to iterate over all the data and, if built in debug mode, could cause an assertion failure.

Now we return the sequence’s end when the data appears to be malformed and we never look at more than the last 6 bytes in the sequence.
2014-03-03 13:48:12 +07:00
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
1781f4a605 Use proper iterate macro for temporary 2014-03-03 00:20:02 +07:00
Allan Odgaard
d700447d8b Remove unused API 2014-03-02 21:10:15 +07:00
Allan Odgaard
be92d71c46 Allow disabling indent corrections when typing on empty lines
This is generally desired when the indent of a new line does not (necessarily) depend on lines above it, but where we otherwise do want indent corrections, e.g. HTML.
2014-03-02 20:06:31 +07:00
Allan Odgaard
a180c24539 Run will/did save and activate/deactivate callbacks in sequence
Previously only the most specialized callback(s) would run. For example creating a command scoped to “source” with “callback.document.will-save” for semantic class would never run for Ruby, Python, etc. because the Source bundle has a “Make Script Executable” callback scoped specifically to “source.ruby”, “source.python”, etc.
2014-03-02 13:15:34 +07:00
Allan Odgaard
4609378cdc Introduce bundles::kItemTypeMost constant 2014-03-02 13:13:04 +07:00
Allan Odgaard
e71be609e0 Use new pasteboard history browser
Closes #481
2014-03-02 12:13:06 +07:00
Allan Odgaard
0e0a6e0252 Fallback on system pasteboard when history is empty
This is for the next/previous methods, the method that returns current already would fallback on the system pasteboard.
2014-03-02 12:13:06 +07:00
Allan Odgaard
95508d9757 Add new pasteboard history browser 2014-03-02 12:12:57 +07:00
Allan Odgaard
34d9a6770f Add API to (temporarily) disable session saving 2014-03-01 08:48:28 +07:00
Allan Odgaard
7483829245 OakPasteboard: Setting currentEntry now updates system clipboard 2014-02-28 19:20:21 +07:00
Allan Odgaard
72f4811d0b Use @property with @dynamic for ‘primitiveOptions’ property 2014-02-28 19:18:28 +07:00
Allan Odgaard
c0c8a073b9 Avoid property access in fetch predicate 2014-02-28 14:33:20 +07:00
Allan Odgaard
79a47ee277 Don’t store pasteboard entries in an ordered collection
Instead we date stamp each entry and do a sorted fetch (with a limit of one) to find next/previous entry (when required).

The reason for moving away from an ordered collection is twofold, the main reason is that NSArrayController does not support ordered collections, so we lose one of the advantages of switching to CoreData. The secondary reason is that using an ordered collection requires that we use an index for “current item” (or maybe liberal use of indexOfObject:) and it’s problematic to ensure that the index is kept 100% in sync with the entries in the collection (especially with bindings and delayed actions).
2014-02-28 14:28:03 +07:00
Allan Odgaard
13e810e8be Add exception handler for NSManagedObjectContext’s save: method
If an exception is thrown, a dialog is shown. This isn’t very user friendly, but the goal is to call attention to the problem, as I wouldn’t expect any exceptions to be thrown by this method, but I have seen multiple “optimistic locking failure” exceptions despite single-app / single-thread access to the persistent store.
2014-02-27 12:36:33 +07:00
Allan Odgaard
c9f1cd2a84 Enable “Uncommitted Documents” in file chooser 2014-02-27 11:41:26 +07:00
Allan Odgaard
2389e2c589 Recreate SCM info when re-opening file chooser
This is required for showing SCM status for “Open Files”. Previously, closing the file chooser with “Open Files” selected and re-opening it, would not have SCM info for the open files.
2014-02-27 11:30:45 +07:00
Allan Odgaard
56ae96982d Refactor file chooser source selection 2014-02-26 23:00:59 +07:00
Allan Odgaard
1a4314fce2 Wrap initialize code in dispatch_once
This is only done for code where running it twice would actually cause a problem.

Dispatch_once is favored over a static boolean only because it seems to carry slightly more semantic information.
2014-02-26 19:36:54 +07:00
Allan Odgaard
0663a39bcf Abort copy file if target is child of source 2014-02-26 08:29:42 +07:00
Allan Odgaard
4e1cdb4c9e Snippets with overlapping fields could cause multiple carets
For example in ruby inserting ‘env⇥’, deleting the initially selected letter, and typing B or S, would insert an additional caret (it was actually inserted in the previous step, but not visible since it was overlapping the existing caret).

The API lack proper support for returning the new caret range so we are using a heuristic to figure out which of the returned ranges correspond to our caret. Ideally the API would be updated.
2014-02-26 08:29:42 +07:00
Allan Odgaard
6ec2f26d2c Don’t access user’s contacts during launch
Instead we access it when either we need to submit a crash report, when the preferences window open (where the contact address is shown), or when creating a new bundle (where email is also used for the bundle’s contact).
2014-02-23 17:10:31 +07:00
Allan Odgaard
4c09310c14 Update Projects preferences pane, adding 3 new options 2014-02-23 14:45:26 +07:00
Allan Odgaard
faedd67299 Move some user defaults keys to Preferences/Keys.h 2014-02-23 13:36:47 +07:00
Allan Odgaard
3baea707e2 Fix typo 2014-02-23 08:33:38 +07:00
Allan Odgaard
ae26988b39 If any folding pattern is set as a scoped setting, use it
Previously we would fallback on the grammar’s folding patterns unless ‘foldingStartMarker’ was set, which meant setting just the stop marker or indented folding patterns, would be ignored.
2014-02-22 16:00:00 +07:00
Allan Odgaard
60e8af92e4 Delay saving of pasteboard history by 30 seconds
Since we save the history during applicationWillTerminate: there is (in theory) no reason to periodically save the history, but in case of a crash or similar, we would not get to applicationWillTerminate:.
2014-02-22 15:51:45 +07:00
Allan Odgaard
9fcde0791e Add CoreData index to pasteboard entry content 2014-02-21 22:04:02 +07:00
Allan Odgaard
8b44ab2c41 Avoid duplicate entries on find/replace pasteboard 2014-02-21 21:36:13 +07:00
Allan Odgaard
fbafcfb87e Ignore links when recursively expanding file browser items
Symbolic links can point to ancestor items and cause cycles, which would cause the (recursive) expansion to newer terminate.
2014-02-21 11:51:11 +07:00
Allan Odgaard
4015859bd3 Allow inline expansion of symbolic links (in file browser)
This is enabled by running: defaults write com.macromates.TextMate.preview allowExpandingLinks -bool YES
2014-02-21 11:48:34 +07:00
Allan Odgaard
8956207789 Avoid detached objects in core data store 2014-02-20 22:40:20 +07:00
Allan Odgaard
56a906a0ac Use temporary pasteboards when replaying macros
This applies to search, replace, and (unless disabled) regular pasteboard.
2014-02-20 22:22:55 +07:00
Allan Odgaard
aec82de6e2 Implement kReplace / kReplaceAndFind actions
These are used when replaying macros.
2014-02-20 22:09:36 +07:00
Allan Odgaard
17dca05dba Let editor_t remember (regexp) captures from editor_t::find 2014-02-20 22:09:36 +07:00
Allan Odgaard
aff813203b Find macro actions now populate the search/replace pasteboard
This should be consistent with TextMate 1.x and is required for the replace actions.
2014-02-20 22:09:36 +07:00
Allan Odgaard
362c18c3e0 Record current replace string as part of macro find action
Previously we would only record it if the user invoked a replace action from the find dialog, but the user may invoke “find” from the dialog and then subsequently “replace” via keyboard/menu (where we would not record the string).
2014-02-20 22:09:35 +07:00
Allan Odgaard
95b834ac0a Grammars with no root scope are no longer shown in the UI
Only injection grammars should have an empty root scope, and if so, it does not make sense to allow the user to pick it as document grammar.
2014-02-20 13:14:36 +07:00
Allan Odgaard
520084a08c Limit clipboard history to about 10,000 items
Once we reach the threshold we delete half the history to ensure a good amortized time complexity.
2014-02-20 10:34:49 +07:00
Allan Odgaard
1f74cef1bd Avoid storing ‘false’ (as value) in bundle items
Since we treat a missing key as having the value ‘false’ there is no need to write out keys set to false. This was partly motivated by improving cached data since here we store non-strings as binary property lists, and boolean values are non-strings (not that we have that many keys set to false, but it would e.g. happen if user disable an item and later enable it).
2014-02-19 20:48:13 +07:00
Allan Odgaard
be2eff9825 When replaying fs-events we would not reload changed items
When we see a changed item we drop it from the cache and mark the cache as “incomplete”, indicating that the bundle index should be rebuilt, which in turn causes all known items to be fetched, and the cache will thereby reload the updated entries.

However, when replaying fs-events, we are in a “rebuild index” state and would not re-rebuild the index incase items were dropped.
2014-02-19 20:11:52 +07:00
Allan Odgaard
4f5f20947a Ensure pending bundle index changes are saved during quit 2014-02-19 19:37:39 +07:00
Allan Odgaard
162ba1649c Rename project-state.db → RecentProjects.db 2014-02-19 18:01:00 +07:00
Allan Odgaard
8c9ebc46ea Ignore caret’s “desired X” in positionForWindowUnderCaret:
For example if at column 60 on a line and moving up/down to a shorter line, we remember that column 60 is our desired column position. This would previously be used when returning a position for the caret, e.g. used with clipboard history pop-ups and bundle item disambiguation menus.
2014-02-19 15:41:48 +07:00
Allan Odgaard
b1ec5cf4c2 Use CoreData for storing clipboard history
Previously this was stored in NSUserDefaults. The problem with that approach is that if large items were stored in the history, it would cause slowdowns, presumably by periodic writing the entire user defaults to disk.
2014-02-19 15:34:07 +07:00
Allan Odgaard
a8c269e75c Call ‘atos’ via xcrun 2014-02-18 23:09:53 +07:00