101 Commits

Author SHA1 Message Date
Allan Odgaard
caaa36161d Change most fprintf log statements to using os_log 2020-05-04 19:20:04 +07: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
Ronald Wampler
1b33f6e36d Always uppercase the encoding charset
Apple writes the encoding charset (e.g., com.apple.TextEncoding) in
all lowercase (at least since macOS 10.9); however, TextMate assumes that the
encoding will always be uppercase. So in order to avoid any issues with case
mismatches, when setting the charset, uppercase the given string.

See http://lists.macromates.com/textmate/2018-April/040602.html
2018-04-25 21:43:51 +07:00
Allan Odgaard
f7f6444885 Only load charset (encoding) frequency database once
Previously this database was loaded each time a file of unknown encoding was read, which could add a significant overhead when using “find in folder” with a large database and many files with unknown encoding.
2017-10-03 09:43:43 +02:00
Allan Odgaard
783d073098 Opening document with no newlines no longer default to LF
Since creating new untitled documents go through the same “open” code they would have their newlines set to LF, this is no longer the case, so the global (or targeted) lineEndings setting now decide what to use (when saving the document).

Currently creating an untitled document from a buffer (e.g. `echo foo|mate`) will do newline detection and thus will ignore user settings during save, if the buffer had any newlines during initialization.

This may or may not be desired. Probably it should do newline detection when the data is provided by the user, but not when it is based on “internal” data, for example a command with “New Document” as output location.
2016-11-02 23:02:18 +07:00
mathbunnyru
440414f96c Use nullptr in all C++ files instead of NULL
This brings us a bit of extra type safety, for example where an integer is expected, nullptr should be disallowed by the compiler (unlike NULL).
2016-10-22 21:40:14 +07:00
Allan Odgaard
b99fd4891f Make TextMate smarter when learning file type associations from path
We now check if an installed bundle has an extension that match the path, and if it is longer than the simple extension, we use the one from the bundle.

This would be relevant for file paths like ‘.git/config’, ‘CMakeLists.txt’, and ‘foo_spec.rb’.
2016-09-05 09:48:15 +02:00
Allan Odgaard
c5abbb755b Higher value from path::rank now means better match 2016-09-04 20:17:42 +02:00
Allan Odgaard
24ae5b0d21 Move grammars_for_path to the file framework 2016-09-04 20:17:42 +02:00
Allan Odgaard
fe991f7b4b Improve error message for failure during save 2016-08-29 07:51:45 +02:00
Allan Odgaard
46fb745bbe Use perrorf when printing errors with dynamic strings
Also revise error messages to be more consistent.
2016-08-28 17:25:26 +02:00
Allan Odgaard
dbdfa3c6af Add identifying information to perror output 2016-08-21 12:09:30 +02:00
Allan Odgaard
a8f1d63225 Use current run loop instead of main dispatch queue for write callback 2016-08-05 22:16:30 +02:00
Allan Odgaard
8e0948ca0d Use current run loop instead of main dispatch queue for read callback
This is similar to commit 26e66b887a but this change affects reading files.

If we have a command that runs on `callback.document.did-save` and that command writes to another (open) document, TextMate would hang as the save completion handler is indirectly invoked by `dispatch_async(dispatch_get_main_queue(), …)` so the main queue is blocked throughout the execution of the completion handler, and this completion handler may run commands (`callback.document.did-save`) which means it runs a local event loop, and thus while running this event loop, a new event can arrive which tells TextMate that files have changed (and should be reloaded).
2016-08-05 22:11:16 +02:00
Allan Odgaard
26e66b887a Use current run loop instead of main dispatch queue
While the previous changes were motivated by the tests, this one affects TextMate in that we run a local event loop if we want to wait for commands to finish, but as we previously used the main dispatch queue to send back command results, it meant that we could not wait for command completion from a block running in the main queue.

Currently the code works around this by using performSelector:withObject:afterDelay: when there is a chance of being in a local event loop, which is no longer required.
2016-07-10 11:29:42 +02:00
Allan Odgaard
0e5e448295 Remove unused file type argument to file::save 2016-07-08 10:13:47 +02:00
Allan Odgaard
b209d81645 Make file::type_from_path a public function 2016-06-29 16:32:01 +02:00
Allan Odgaard
5361e287f9 Do not handle file type sniffing in file::open
This disables support for showing the user a selection sheet when the file type is unknown, instead we fallback on text.plain.
2016-06-29 11:37:29 +02:00
Allan Odgaard
ca01850b7c Make file::type_from_bytes a public function 2016-06-29 11:37:28 +02:00
Allan Odgaard
f78bfd306d Remove unused constant for “mixed newlines” and callback related to this 2016-06-29 11:37:28 +02:00
Allan Odgaard
b72091b3bb The encoding::charset_from_bom function now return “«charset»//BOM” 2016-06-21 19:32:47 +02:00
Allan Odgaard
7b2e296907 Remove BOM support from encoding::type 2016-06-21 19:30:22 +02:00
Allan Odgaard
4b3d959c85 Remove explicit BOM handling from the file framework 2016-06-21 19:28:29 +02:00
Allan Odgaard
f60e0dad98 Use text::transcode_t instead if iconv API 2016-06-21 18:33:20 +02:00
Allan Odgaard
8483826fae Always use '\0' as fill value when creating a string buffer 2016-06-18 10:34:08 +02:00
Allan Odgaard
417193e089 Update link dependencies for all targets
Some targets were including headers from frameworks not specified in their link dependencies. For a clean build this could cause an issue because the header was not available at the time of building the target.

The updated link dependencies are also based on what a target’s tests require. Ideally tests would have separate link dependencies, but as we don’t want to maintain this manually, this will have to wait until the build system automatically handles link dependencies.

Currently the commit command uses constants from the CommitWindow framework but should actually not be linked with it. However, the optimizer will strip dead code, so it should not result in much if any difference in the resulting binary and does solve a build dependency issue.
2016-05-07 13:00:55 +02:00
Allan Odgaard
57d0f29cdc Replace in folder would lose byte-order-mark for UTF-8 documents
This would only happen for documents not already open when performing the search and replace (in folder).
2015-10-28 15:37:04 +07:00
Allan Odgaard
0edcddccfa Do proper escaping when constructing a glob from file path 2015-04-30 15:15:57 +02:00
Allan Odgaard
c6c388e088 Add explicit link dependency 2015-04-30 15:15:57 +02:00
Allan Odgaard
30be46a166 Support discontinuous selections in command input API 2015-03-08 14:21:59 +07:00
Allan Odgaard
40879d5683 Replace sizeofA macro with range-based for loop or std::begin/end 2015-03-05 16:38:09 +07:00
Allan Odgaard
f9cef6959b Handle searching files that end with an incomplete UTF-8 sequence
Previously this would cause infinite looping as we tried to read more to complete the UTF-8 sequence.
2015-01-21 15:55:16 +07:00
Allan Odgaard
aeb9ab7d00 Move server.h to the only framework left using this legacy API 2014-12-25 09:33:13 +01:00
Allan Odgaard
3a86535022 Move boost crc include to PCH
Also use unsigned integer for the checksum.
2014-10-18 12:36:23 +02:00
Allan Odgaard
58f98cad23 Ignore unknown file types when finding document’s file type
The problem is if the user sets a certain file type to open with grammar X and then uninstalls X, there will still be a setting binding the file type to X which means we skip trying to find another suitable grammar.
2014-10-13 23:20:25 +02:00
Allan Odgaard
3feec01e66 Add CRC 32 member function to io::bytes_t 2014-10-07 18:23:25 +02:00
Allan Odgaard
d39ae2a7df Our grow calculation would fail to grow when given a size of one 2014-08-14 20:37:38 +02:00
Allan Odgaard
5715ebf754 Allow a limit to be passed to file::read_utf8
Currently the API does not allow the caller to know that the data was actually truncated.
2014-07-08 17:49:42 +02:00
Allan Odgaard
e81286b0cd Remove unused include 2014-05-16 22:11:28 +07:00
Allan Odgaard
0286a10cbc Remove unnecessary code 2014-05-16 22:11:28 +07:00
Allan Odgaard
7fb02603b5 Revert "Disable threaded saving as a workaround for stall during quit"
This reverts commit 0b41947412.
2014-04-29 06:59:39 +07:00
Allan Odgaard
0b41947412 Disable threaded saving as a workaround for stall during quit
The problem is that during quit the OS will run a local event loop until we reply to the terminate event. In this local event loop we cannot use performSelector:withObject:afterDelay: but that is required to not block the main dispatch queue.
2014-04-28 21:45:59 +07:00
Allan Odgaard
7ea524b936 Drop the oak::server_t abstraction 2014-04-28 21:45:59 +07:00
Allan Odgaard
39b94e6ac3 Harmonize whitespace and add trailing newline 2014-04-14 14:26:52 +07:00
Allan Odgaard
e379021492 Assert that we are not blocking the main queue 2014-04-11 10:57:09 +07:00
Allan Odgaard
fb80ffd272 Use custom test system for testing the ‘file’ framework 2014-04-08 15:43:20 +07:00
Allan Odgaard
91e8064439 Add to_s for file_status_t 2014-03-31 08:27:16 +07:00
Allan Odgaard
78cb28db9e Fix infinite loop in folder search for multi-byte encoded files
This would happen if a multi-byte encoded file ended with a partial code point, as we would continue to try and read more data to finish decoding.
2014-03-23 22:47:16 +07:00
Allan Odgaard
45867e7e0a Do not return void from constructor (error with clang-503.0.38) 2014-03-13 20:51:00 +07:00