4258 Commits

Author SHA1 Message Date
Allan Odgaard
afe008e028 Allow invalid ranges to be passed to nsRangeForRange:
Since this is internal API it should not be necessary to sanitize the range, but based on textmate/bugs#34 it is causing a lot of crashes on macOS 10.15.
2019-12-15 12:06:56 +07:00
Allan Odgaard
362d870563 fixup! Fix issue with FSEvents wrapper when dealing with multiple volumes
The updated code was leaving a trailing slash on directory paths which would make cache lookups fail.
2019-10-28 10:15:13 +01:00
Allan Odgaard
9565bb4910 Add NSStandardKeyBindingResponding to OakTextView’s interface 2019-10-27 15:27:03 +01:00
Allan Odgaard
0f66772bdb Remove whitespace. 2019-10-27 15:25:53 +01:00
Allan Odgaard
9f339bfcf6 Do not hardcode the type of utf8::iterator_t
This is to allow it to be used with both const and non-const character buffers (the latter being returned from std::string’s data member function).
2019-10-27 15:25:35 +01:00
Allan Odgaard
d5440d86e8 For bundle commands we now write the script to ~/Library/Caches
Previously we used the system’s temporary directory and removed the script after use.

This is because macOS 10.15 will “call home” (notarization?) when executing a new script (that it has not seen before), so with an unstable network connection, running commands could take several seconds.
2019-10-27 15:24:08 +01:00
Allan Odgaard
aff1273d53 Context menu items for tabs would be disabled in full screen mode
Apparently the window’s delegate is not used for context menu actions in full screen mode, although NSApp’s targetForAction: does find the receiver, so this appears to be a framework bug.
2019-10-27 15:20:14 +01:00
Allan Odgaard
82c4e272a4 Remove unnecessary crash reporting diagnostics 2019-10-27 15:18:20 +01:00
Allan Odgaard
5a6cf83e2d Fix issue with FSEvents wrapper when dealing with multiple volumes
The specific issue being addressed is macOS 10.15 where the mount point for ~/Library/Application Support is under /System/Volumes/Data so our assertion that the relative path received in our callback can be appended to the mount point, to match the path being observed, is false.

As a workaround we call realpath() on the path we wish to observe, observe that path, and in our callback we calculate the relative path from the real observed path, and append that to the requested path.

In theory the caller could be made responsible for expanding paths to their real path, but the current abstraction allows observing non-existing paths, which is why it needs to handle this path rewriting.
2019-10-27 15:17:03 +01:00
Allan Odgaard
6f68ea7303 Do not use custom white I-beam cursor on macOS 10.14
The I-beam cursor on macOS 10.14 has a white outline that makes it visible when used with dark themes.
2019-10-14 14:47:38 +02:00
Allan Odgaard
2560ce697d Change placeholder text for license key
The old text (example key) was easily mistaken for having entered a license key into the dialog.
2019-10-14 08:56:48 +02:00
Allan Odgaard
a08987b097 Explicitly zero weak pointer to tab bar view when removed from superview
If one event cycle triggered multiple re-layouts, we could end up reusing a tab bar view that had been removed from its superview because the weak pointer had not yet been cleared (as the view hadn’t yet been fully released).

This could happen during window construction in a scenario like this:

1. Window gets created at some size, tab bar views are created
2. Window size gets restored causing some tab bar views to be removed
3. Active tab gets restored bringing an overflow tab into the visible area, re-using a removed view
2019-10-14 08:38:52 +02:00
Allan Odgaard
4c7b98d0bf Remove superfluous spacing for aligned assignments 2019-10-07 21:28:16 +02:00
Allan Odgaard
079377ed49 Require macOS 10.12 and remove compatibility checks 2019-10-07 21:28:16 +02:00
Allan Odgaard
4b4e5fca8b Remove code required for compatibility with 10.10 and earlier 2019-10-07 21:28:16 +02:00
Allan Odgaard
990672d1f7 Support macOS 10.11
We don’t yet rely on any 10.12 specific API other than os_log which can be skipped without user impact.

Unfortunately when trying to build for 10.10 using latest Xcode/SDK the linker gives an error for missing symbol: _objc_loadClassref.

Going forward we will require 10.12 but as there is no non-beta build for 10.11 users yet, I wanted to make one.
2019-10-07 12:32:01 +02:00
Max Brunsfeld
ecca53d796 Don't push to the parse stack for rules without while or end patterns 2019-10-07 11:44:25 +02:00
Allan Odgaard
ce4a1f392f Preserve meta data when saving using NSFileManager’s replaceItemAtURL:
We skip extended attributes and file access control lists on non-local file systems since this has caused problems int he past.
2019-10-06 10:49:10 +02:00
Allan Odgaard
3c7895f578 Simplify code by using NSOffsetRect 2019-10-06 10:35:55 +02:00
Allan Odgaard
d9ac41d790 Add checkbox in Preferences for the disableTabAutoClose setting 2019-09-15 11:26:41 +02:00
Allan Odgaard
4fbc9ee6ea Fix indentation (spaces → tabs) 2019-09-05 10:01:10 +02:00
Ronald Wampler
4820e876d2 Only allow navigating bookmarks in the touch bar
See https://lists.macromates.com/textmate/2019-August/041082.html
2019-09-05 09:59:44 +02:00
Allan Odgaard
562c6f519b Add missing boundary check when accessing undo/redo stack 2019-08-26 21:45:25 +02:00
Allan Odgaard
7116dd777f Workaround for potential stall when calling mate with inactive TextMate
The issue appears to be that accessing the clipboard, as part of setting up a normal document window, will stall when trying to connect to the system’s clipboard server.

Here’s the relevant stack trace:

    -[OakPasteboard checkForExternalPasteboardChanges]
      -[NSPasteboard stringForType:]
        -[NSPasteboard _dataForType:securityScoped:]
          -[NSPasteboard _dataForType:index:usesPboardTypes:combinesItems:securityScoped:]
            -[NSPasteboard _dataWithoutConversionForTypeIdentifier:securityScoped:]
              CFPasteboardCopyData  (in CoreFoundation)
                ___onqueue_CFPasteboardRequestDataFromDaemon_block_invoke.341
                  usleep  (in libsystem_c.dylib)
                    nanosleep  (in libsystem_c.dylib)
                      __semwait_signal  (in libsystem_kernel.dylib)
2019-08-26 21:34:52 +02:00
Allan Odgaard
36dc1374f9 Revert "Add debug output when TextMate is activated via mate"
This reverts the following 3 commits:

- commit 306d46ec71
- commit eecfe6e619
- commit 2ffc74ad8b
2019-08-26 21:19:17 +02:00
Allan Odgaard
cf3fe7c575 Fix buffer overflow bug
Without the boundary check we would write one byte beyond the end of the stack-allocated ‘first’ array.
2019-08-25 13:16:10 +02:00
Allan Odgaard
306d46ec71 Add even more debug output for when TextMate is activated via mate 2019-08-21 11:51:26 +02:00
Allan Odgaard
5e96d41a3d Look for numeric prefix when duplicating a file and increase it if found
For example if we have a directory with files named 001-foo.txt, 002-bar.txt, and 003-fud.txt, duplicating one of these will result in the duplicate starting with 004.

Also improve support for finding dates in file names being duplicated. Previously we only looked for YYYY-MM-DD but now we also support YYYY_MM_DD and YYYYMMDD. If a date is found in the file name being duplicated, it is replaced with the current date in the duplicate.
2019-08-08 21:37:42 +02:00
Allan Odgaard
f33ba968a8 Don’t ignore result from writeObjects: 2019-08-02 21:07:04 +02:00
Allan Odgaard
454b1b4644 Use availableTypeFromArray: instead of checking types array directly 2019-08-02 21:06:21 +02:00
Allan Odgaard
774e66c009 Ignore ‘types’ in implementation of writeSelectionToPasteboard:types:
The issue is that the types requested may be ‘NSStringPboardType’ but that symbol is deprecated (starting with 10.14), yet the replacement (‘NSPasteboardTypeString’) is not string-equivalent, therefore our simple string comparison would fail.

This effectively broke services starting with 1ef78b3af7 (where we adopted the new symbols).

Implementation of validRequestorForSendType:returnType: does not appear to be a problem, as that method is called with both ‘NSStringPboardType’ and ‘NSPasteboardTypeString’.

Also switched to using NSPasteboard’s writeObjects: so we don’t have to explicitly deal with the type of the data we write to the pasteboard (presumably NSString will declare it using both the old and new type).
2019-08-02 21:03:39 +02:00
Allan Odgaard
8f685ff25c Use std::clamp instead of oak::cap (C++17) 2019-08-01 10:23:55 +02:00
Allan Odgaard
253fc90448 Remove ‘requires’ member function since it clashes with a C++20 keyword
This member function was never called by anyone.
2019-08-01 10:17:20 +02:00
Allan Odgaard
acfee9901c Use ‘NSInteger’ for result of selectedRow (instead of legacy ‘int’ type) 2019-08-01 10:11:24 +02:00
Allan Odgaard
77bc9f7a6f Remove test for localized folder names as it does not work (10.14)
I cannot find any information online about Apple dropping support for this, but I also cannot make it work, and it wouldn’t surprise me if they view localized folder names as a security problem.
2019-07-16 20:02:42 +02:00
Allan Odgaard
dae1103728 Update LINK declarations 2019-07-16 19:42:29 +02:00
Allan Odgaard
36f414dbea Add missing include in test file 2019-07-16 19:42:20 +02:00
Allan Odgaard
f21d570b73 Remove test for VOL_CAP_INT_EXCHANGEDATA
This is no longer supported (with APFS) so there is no reason to keep this code around.
2019-07-16 14:29:20 +02:00
Allan Odgaard
eb4e0bfcd0 Update tests to reflect how the code works
The “matching pair” move behavior was changed in 7f99c4cbc7
2019-07-16 14:27:28 +02:00
Allan Odgaard
f47a7b5f53 Code to bump date in filename is no longer a testable separate function 2019-07-16 14:24:07 +02:00
Allan Odgaard
eecfe6e619 Add more debug output for when TextMate is activated via mate
Related to 2ffc74ad8b
2019-07-16 08:33:05 +02:00
Allan Odgaard
b176bf8f9a Use number formatter for count in Find All / Replace All status text
The Find dialog was already using number formatters, but the tool tips shown in the text view (when doing searches or replacements without going through the find dialog) were not.

This makes a difference when the count is > 999, as it will then format the number with thousand separators.
2019-07-14 11:26:31 +02:00
Allan Odgaard
dfd5f85fb5 Remove unnecessary Info.plist file from Find framework 2019-07-14 10:59:30 +02:00
Allan Odgaard
63e82b9bc0 Drop localization support in Find dialog
This was unnecessary indirection as we don’t generally lookup strings for the UI (so TextMate is not actually localizable) and the catalog for the strings we did look up was actually out of date.
2019-07-14 10:57:27 +02:00
Allan Odgaard
6b3c8747e7 Remove unused localization strings 2019-07-14 10:46:31 +02:00
Allan Odgaard
a7542c7ea1 Retain current thread’s run loop 2019-07-13 11:43:24 +02:00
Allan Odgaard
f5d0f38cc7 Don’t update NSUSerDefaults in OakTabBarView’s initialize
The use of an animator proxy is causing the initialize method to be called during animation, and when registering user defaults in initialize, we may trigger key/value observers to be notified, which for this code can result in a crash in OS code with the message: “Trying to recursively lock an os_unfair_lock”.
2019-07-13 11:18:20 +02:00
Allan Odgaard
066e020265 Ensure temporary std::string stays in scope when using its data 2019-07-13 11:02:25 +02:00
Allan Odgaard
2ffc74ad8b Add debug output when TextMate is activated via mate
Some users report a significant delay from executing mate until the TextMate window is brought to front.

The debug information can be extracted by running the following in a terminal:

    log show --predicate 'subsystem = "com.macromates.TextMate" && category = "BringToFront"'

Alternatively use `stream` instead of `log` to get a live stream of debug output.

See `man log` for options such as `--start date/time` (to limit the query to e.g. the last 10 minutes)
2019-07-13 10:20:09 +02:00
Allan Odgaard
168915307d Assign small icon to sieve scripts (file browser etc.) 2019-07-13 08:23:06 +02:00