4239 Commits

Author SHA1 Message Date
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
Allan Odgaard
087e0ce0a7 Import os/log.h when deployment target is macOS 10.12 or later 2019-07-13 08:22:00 +02:00
Allan Odgaard
a9b5925f57 Saving a file would lose existing file permission flags 2019-07-08 13:07:28 +02:00
Allan Odgaard
58414e9def Resolve potential symbolic link in path to save
Trying to save a file as /path/to/symlink will fail with “file does not exist” using the new NSFileManager API, even when the symbolic link does point to an existing file.
2019-07-08 07:27:36 +02:00
Allan Odgaard
824981eaa2 Produce error string for any failure from saving with NSFileManager 2019-07-07 22:10:11 +02:00
Allan Odgaard
423e8e9a43 Allow disabling atomic save via .tm_properties
This is done by setting `atomicSave` to one of the following values:

    always           Always use atomic saving (default)
    externalVolumes  Use for non-internal volumes (e.g. USB drives)
    remoteVolumes    Use for non-local volumes (e.g. network mounts)
    never            Never use atomic saving
    legacy           Always enabled, but do not use NSFileManager

Setting it to `externalVolumes` also includes `remoteVolumes`.
2019-07-07 20:52:50 +02:00
Allan Odgaard
538283cc67 Use NSFileManager’s replaceItemAtURL:… as default way to save atomically
NSFileManager’s approach is inferior to exchangedata(), but as this feature is no longer supported with Apple’s default file system (APFS), there is little reason to maintain our own implementation of the fallback code required when we cannot use exchangedata(), especially as the OS know more about file references (aliases), metadata, and other stuff that should be preserved when writing a new (replacement) file.

In theory the NSFileManager strategy can fail to create the temporary destination, in which case we will pass NULL to open() and crash.

Will fix this in a later commit.
2019-07-07 20:52:50 +02:00
Allan Odgaard
8f3f3d9d16 Update deployment version for xibs to 10.12
This was done using search and replace. Presumably it should be done in Xcode so that it can adjust the xib for the new deployment target, otherwise what is the point of storing deployment version in the xib and provide it as a command line argument to the xib compiler as well (only to get a warning if the versions do not match)?
2019-07-07 18:03:30 +02:00
Allan Odgaard
997e70059a Switch to Objective-C for the implementation of atomic saving
The most appropriate API for dealing with temporary files and atomic saving seems to be NSFileManager.
2019-07-07 11:37:59 +02:00
Allan Odgaard
4c4822e1ca Make it easier to change (atomic) saving strategy
The intermediate_t type now wraps the actual saving strategy to make it easier to change strategy based on the destination file system, user preferences, or other factors.
2019-07-07 11:12:16 +02:00
Allan Odgaard
ba43f2ec5e The $1-n variables in nested replacements weren’t cleared properly
When searching for a regular expression with captures, we have $1-n available in the replacement (format) string.

If this format string does further replacements with optional captures (e.g. /^(_)?foo/) then $1 would be inherited from the parent match, when the optional capture did not match anything.

This bug was introduced in 0b1496011f.
2019-07-06 19:35:51 +02:00
Allan Odgaard
1c1358bcce Workaround for missing content when expanding file browser items
The workaround is untested, as I have not found a way to reproduce the issue, but there is some debug output that can be reviewed and hopefully give some idea as to what is causing the issue.

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

    log show --predicate 'process = "TextMate" AND eventMessage CONTAINS "loadChildrenForItem:expandChildren:"'
2019-07-06 18:18:56 +02:00
Allan Odgaard
91d7aecf1b Changing BundleItemChooser’s hasSelection property now update item names
The items can be named “Do something with «unit» / Selection” and TextMate will show the proper title based on whether or not there is a selection, e.g. “Diff ▸ Document With Clipboard” versus “Diff ▸ Selection With Clipboard”.

Previously though, the item titles were not re-generated when changing the hasSelection property, so the user could be presented with stale titles until some other action triggered re-generation, e.g. indicating that an adaptive item works on current line when there is a selection.
2019-07-04 10:51:23 +02:00
Allan Odgaard
dc47206829 fixup! Make OakChooser windows inherit from NSWindowController 2019-07-04 10:36:53 +02:00
Allan Odgaard
11d67f3a22 Avoid NSString’s deprecated percent encoding methods 2019-06-30 10:32:45 +02:00
Ronald Wampler
b1fdd4377b Allow customization of DocumentWindowController touch bar items 2019-06-30 10:32:45 +02:00
Ronald Wampler
2294d369d0 Add accessibility support for DocumentWindowController's touch bar 2019-06-29 19:21:45 -04:00
Ronald Wampler
d8db03c426 Add initial touch bar support for OakTextView
This adds buttons for inserting/removing bookmarks and navigate them.

Since the function keys were replaced with the touch bar, there currently is no other way to set and navigate bookmarks other than these buttons so make their visibility priority high.
2019-06-29 19:21:45 -04:00
Ronald Wampler
d8b17a1f06 Let DocumentWindowController's touch bar support nested touch bars 2019-06-29 19:21:45 -04:00
Allan Odgaard
1ef78b3af7 Rename symbols to what’s expected by the 10.14 SDK 2019-06-29 20:14:15 +02:00