Commit Graph

46 Commits

Author SHA1 Message Date
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
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
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
5c02b4ff5c Use cap’n proto for bundle index
This makes loading time roughly twice as fast, although some of the speed gain is because we no longer need to convert CFPropertyListRef → plist::any_t.
2013-08-18 17:29:29 +02:00
Allan Odgaard
5d5399ecd9 Add member data accessor for cache_t’s content filter function 2013-08-16 22:40:09 +02:00
Allan Odgaard
62a16dd6a9 Do recursive rescan of updated bundles
Previously we would rescan the parent path which was effectively a no-op.

Also pass the “recursive” flag from fs-events to cache_t::reload.
2013-08-02 15:30:48 +02:00
Allan Odgaard
171cf05981 Use cache_t::erase when uninstalling a bundle 2013-08-02 15:26:59 +02:00
Allan Odgaard
9fd20df7b6 Remove code to cleanup old cache files 2013-08-01 22:33:19 +02:00
Jacob Bandes-Storch
5bfd29b604 Move load_bundles to bundles framework 2013-07-28 21:57:51 +02:00
Jacob Bandes-Storch
d89571956d Move fs_cache to plist framework 2013-07-28 21:57:50 +02:00
Jacob Bandes-Storch
f2df57df60 Rename “index.{cc,h}” to the more appropriate “item.{cc,h}” 2013-07-28 21:57:31 +02:00
Allan Odgaard
241d105dc9 Skip loading Bundles → TextMate → Update Notification (⌘Q)
The bundle item is causing ⌘Q to act subtlety different (issue #1031) but as we still see a lot of users on old versions, the item is still valuable to keep around.
2013-06-22 21:02:45 +07:00
Allan Odgaard
ed9396ed84 Workaround for a wrong bundle index
This is work in progress, the reason why the situation arise has not yet been found and there are likely other ways in which the index can be wrong/stale (based on user reports like issue #998).
2013-06-15 16:05:48 +07:00
Allan Odgaard
05bb8d3304 Log malformed UUID incase of error
This is instead of showing “no valid UUID” (which could mean either missing or malformed).
2013-05-26 13:16:22 +08:00
Allan Odgaard
cdb75619ca Add completion callback to installBundle: 2013-04-23 18:52:08 +07:00
Allan Odgaard
34d92253dd Don’t log unchanged sources as failures 2013-04-13 22:37:51 +07:00
Allan Odgaard
931b56f45c Fix crash related to updating bundles
Since we get the failed sources by a const reference it is only live during the scope of the caller, and our use of blocks makes that scope shorter than the called block’s full scope.
2013-04-10 18:12:49 +07:00
Allan Odgaard
0111e6d089 Rework bundle update scheduling
We now store the time of last check in user defaults instead of via extended attributes on the source(s) and do a check every third hour, except of errors, where we retry after 30 minutes.

We now also check for bundle updates even if the sources hasn’t been updated. This is incase we previously updated a source but failed to then update bundles, these will now be updated when we retry, rather than next time the source index has updates.

Overall the code should be simpler and thus more robust. The text in the Bundles preferences page has also been improved slightly in that it will now tell the user if there was a problem updating the bundles, although for the specifics, the user will need to grab the log.
2013-04-09 15:39:38 +07:00
Allan Odgaard
58b101a7db Improve error log message for duplicate UUID
We now output the path of the item which use the same UUID.
2013-04-09 15:39:38 +07:00
Allan Odgaard
8358ffb578 Add “find bundle for new items” API
We need this when installing standalone bundle items, saving macros, and when creating items in the bundle editor without a bundle selected.

The user experience of this code is however rather poor in that you can’t actually crete new bundles, the dialog text is not specific, and the logic for what bundle to preselect can be improved (prefer previously created bundle falling back on a local bundle, if any).
2013-03-27 14:15:54 +01:00
Allan Odgaard
8888865f2c Use initializer list constructor for std::map (C++11) 2013-03-27 13:41:07 +01:00
Allan Odgaard
9af77ef3ab Wrong path was rescanned when changing bundles 2013-03-26 21:18:18 +01:00
Allan Odgaard
9c37d61737 Show alert for unimplemented functionality 2013-03-26 16:21:52 +01:00
Allan Odgaard
c1b8cc5454 Force index rescan after bundle (item) install 2013-03-26 16:11:20 +01:00
Allan Odgaard
bffa2eef10 Move bundle installing to BundlesManager 2013-03-26 16:00:53 +01:00
Allan Odgaard
099f7c60ea Improve bundles index code
By making it part of the BundlesManager singleton we can work with the event loop to coalesce reloads and delay saving the index.
2013-03-25 22:56:49 +01:00
Allan Odgaard
5d8f4998fd Update BundlesManager binding properties 2013-03-25 19:46:28 +01:00
Allan Odgaard
97eec0dc9a Force bundle reindex after install
Fixes #85.
2013-03-25 17:57:40 +01:00
Allan Odgaard
2969af3cbd Provisional API for forcing reload of bundles 2013-03-25 17:54:19 +01:00
Allan Odgaard
5769b16780 Rework bundle install code
We now use dispatch queues for updating bundles and bundle sources.

The determinate progress indicator is presently gone and so is the detailed info about which dependent bundles are being installed.
2013-03-25 17:31:03 +01:00
Allan Odgaard
a24858e63c Store bundle index in ~/Library/Caches 2013-03-25 16:41:58 +01:00
Allan Odgaard
d1a6c854a1 Add API to control bundle auto-updating 2013-03-25 13:04:40 +01:00
Allan Odgaard
75234faaa1 Minor style changes 2013-03-25 12:54:21 +01:00
Allan Odgaard
37590bd3fd Switch to new bundle loading code 2013-03-25 12:48:39 +01:00
Allan Odgaard
14ff3cf047 Add new bundle loading code
Some shortcomings:
1. Cache format is more wasteful (and kept in memory)
2. Device UUID and inode of root folder is not considered when replaying fs-events (we should do a recursive rescan if either changes).

On the bright side, the code better separates loading bundles from disk, and maintaining a disk cache updated via fs-events. This should make it easier to force cache invalidation when updating bundles from within TextMate (so we do not rely on fs-events) and to move bundle loading away from the main thread.

Additionally, by moving the bundle loading code to the bundle manager singleton, we’re introducing a single source of knowledge about “bundles on disk”, regardless of wether they are managed or not.
2013-03-25 12:16:56 +01:00
Allan Odgaard
a36146235a Support disabling “keep bundles updated”
We still update the sources because the user may manually install bundles, and in this case he should install from a recent bundle index.
2013-02-08 12:01:21 +01:00
Allan Odgaard
8c9adfc198 Move some user defaults key to respective framework
Initially I wanted all keys in a single header file but to avoid circular dependencies then this header would need to be in a framework that doesn’t depend on anything else, and the main benefit was only to have a single place to look for which keys exist, but now that we consistently prefix settings keys with ‘kUserDefaults’ then it’s easy to extract all keys via search.
2013-02-08 12:01:20 +01:00
Allan Odgaard
674b171a90 Only check for bundle updates every 4th hour
This should decrease my AWS bill with $4-5/month :)
2013-02-05 08:51:59 +01:00
Allan Odgaard
09337a7ed4 Workaround for flamboyant progress bar
Starting with Lion (I think) the progress bar at the Bundles preferences pane won’t always hide after having installed a bundle.

The progress bar is set to not show when stopped, but for some reason this property does not seem to always be respected, but if we manually set the progress to zero before setting the property (bound to ‘animate’) to NO, then it does properly hide.
2012-12-28 02:47:20 +01:00
Allan Odgaard
88c1210a10 Remove private methods from interface 2012-12-28 02:47:20 +01:00
Allan Odgaard
70979f4eeb ARC: Update BundlesManager framework 2012-12-24 16:50:20 +01:00
Allan Odgaard
b81bac3fda Change {updates → api}.textmate.org
Ideally we’d use the REST_API define setup for a few other targets.
2012-10-01 01:17:00 +02:00
Allan Odgaard
983bce86aa Use @autoreleasepool blocks 2012-09-25 12:30:12 +02:00
Jacob Bandes-Storch
dfdde3283f Use 64-bit: explicit visibility where required 2012-08-28 21:32:47 +02:00
Allan Odgaard
9894969e67 Initial commit 2012-08-09 16:25:56 +02:00