Commit Graph

243 Commits

Author SHA1 Message Date
Allan Odgaard
039b787d37 Use same newline heuristic for open document and find in folder
Previously the heuristic used (when files mix LF, CR, and CRLF) for searching files on disk (find in folder) was not identical to the heuristic used when opening files.

This meant that in rare situations a match could be found at what the find in folder determined to be the n’th line, but when opening the file, it was the m’th line (where m != n).
2016-05-24 21:56:00 +02:00
Allan Odgaard
b202ad3e02 Support arbitrary newlines for search result excerpts
Previously we expected only LF to mark a newline but in theory we can receive CRLF or CR separated text (from files on disk) which would cause incorrect excerpt for matches crossing line boundaries.
2016-05-24 16:49:54 +02:00
Allan Odgaard
7c074b92e5 Show carriage return in search results as <CR> using light grey 2016-05-24 16:39:17 +02:00
Allan Odgaard
2f2451cd5e Refactor code to generate attributed string for search results
This makes it easier to make other transformations than the current tab → em-space.
2016-05-24 16:37: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
edb38b0568 Refactor code to avoid overloading a system method
We were getting a warning because our method was called with nil, but the system method should be called with a non-nil argument.
2015-11-20 13:30:05 +07:00
Allan Odgaard
1e10ef8ac2 Workaround for 10.11 regression 2015-11-18 09:57:29 +07:00
Allan Odgaard
1597e68714 Do not show ‘0’ when holding command (⌘) in search results
The numbers indicate the key equivalent that can be used to jump to the document, but since cb1c516 we no longer support ⌘0.
2015-10-16 20:02:24 +07:00
Allan Odgaard
cb1c51692c Bind Go to Tab → Last Tab to ⌘9 instead of ⌘0
Also avoid binding to ⌘0 in all other ⌘1-n contexts.

This frees up ⌘0 to “Reset Font Size”.
2015-10-16 19:52:47 +07:00
Allan Odgaard
09294626fe Use stringWithCxxString: instead of calling c_str
The problem with the latter is that a C string is null terminated, but we might have null characters in our string.

Furthermore, the stringWithCxxString: can do a little extra work, like check if the string is NULL_STR or (after next commit) fix redundantly encoded multi-byte sequences.
2015-08-30 10:52:56 +02:00
Allan Odgaard
8fe7681ebd Remove unnecessary include of oak/compat.h 2015-08-05 12:31:20 +02:00
Allan Odgaard
0aa9cd8166 Don’t skip binary files when using Find All with open documents 2015-07-31 11:29:42 +02:00
Allan Odgaard
6aad406dde Use symbolic constants for binding properties 2015-07-20 12:10:23 +02:00
Allan Odgaard
a13b75ebc4 Use isEqualToXYZ: or isEqual: instead of isEqualTo: 2015-07-20 12:10:05 +02:00
Allan Odgaard
c416262d82 Limit FFMatch / find::match_t boxing and unboxing 2015-03-05 16:38:09 +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
b4ee16312b Revert "Output frame of find window’s field editor (debug)"
This reverts commit 3d2ac7f371.
2015-01-31 12:05:44 +07:00
Allan Odgaard
812f8146bf Only limit regexp search to 5 MB when operating on disk file
That is, if the file has been opened by the user, there is no size limit on what we will search.
2015-01-29 14:37:56 +07:00
Allan Odgaard
49b784f09c Fix bad logic in if statement
Effectively we would only test if the prefix of a search result was malformed UTF-8, if the search result itself or the suffix was malformed, no error would be shown.
2015-01-21 15:47:27 +07:00
Allan Odgaard
a1a8205467 Find in folder excerpt would be one byte too short for last line
Since it was one byte it would throw an exception if the last character on the line was a multi-byte sequence (as we’d create an NSString with malformed/truncated UTF-8).
2015-01-21 15:38:33 +07:00
Allan Odgaard
29a576ffbe Don’t go via helper for pthread_setname_np
This was previously done because the function wasn’t available until 10.7, but since that is (now) our deployment target, there is no need to wrap the call.
2014-12-25 09:36:01 +01:00
Allan Odgaard
43ab10e45c Increase content compression resistance from high to required
The auto-layout debug mechanisms report that our layout is ambiguous, for example if inserting ‘[self.window visualizeConstraints:_myConstraints]’ at the end of showWindow:.

Closes #1282
2014-12-17 10:13:52 +07:00
Allan Odgaard
bf4cbd33fa Remove NSString* typecast when using to_s helper
This has a small run-time cost but source looks better and theoretically safer code.
2014-11-29 09:53:40 +07:00
Allan Odgaard
a4763ac96c Be smarter about testing if replace text field has focus
Rather than skip the field editor, regardless of which view it belongs to, we check if the first responder is the replace text field’s (current) field editor.
2014-11-29 07:55:48 +07:00
Allan Odgaard
3d2ac7f371 Output frame of find window’s field editor (debug) 2014-11-21 15:17:39 +01:00
Allan Odgaard
5b39bdc98b Remove double semi-colons at end of line 2014-11-14 10:21:34 +01:00
Allan Odgaard
e5009c8415 Remove next/previous properties on result (tree) node
We can get to the next/previous node via the parent pointer, although it has worse time complexity, it’s not something we use in loops, so the extra bookkeeping is not worth it.
2014-11-14 10:20:15 +01:00
Allan Odgaard
2e049ad25f Replace newline and tabs in find dialog’s status text
Previously if searching for something with a newline, the status text would show a literal newline and adapt its height.
2014-11-10 09:24:10 +01:00
Allan Odgaard
ec89bd035b Ensure valid match/excerpt ranges for CRLF delimited files
When searching for either CR or LF in a CRLF delimited file, we effectively match a partial newline and previously the excerpt’s BOL/EOL positions would not take that into account, so the match wasn’t guaranteed to be a subset of the excerpt.

Ideally the document reader should harmonize newlines so that the searcher only sees LF, though currently that is not the case.
2014-11-10 09:22:52 +01:00
Allan Odgaard
7d2ed9a236 Set initial first responder when setting up key view loop 2014-11-06 16:42:22 +01:00
Allan Odgaard
7aea556533 Remove custom NSArray category
We only use the firstObject method which has existed since OS 10.6 (though wasn’t mentioned until the 10.9 FoundationKit release notes).
2014-11-05 10:58:29 +01:00
Allan Odgaard
b581e20ad9 Add wrapper for adding views with auto layout enabled 2014-11-05 00:09:37 +01:00
Allan Odgaard
7ead6d418c Make the OakCreateLabel function more versatile 2014-11-04 22:22:57 +01:00
Allan Odgaard
137e6343ba Add convenience function to setup key view loop 2014-11-04 21:42:09 +01:00
Allan Odgaard
141f8009ac Skip recreating replacement preview if nothing has changed 2014-10-20 22:40:44 +02:00
Allan Odgaard
cf94c1c5ca Clear search gutter marks if find clipboard is changed 2014-10-19 20:26:00 +02:00
Allan Odgaard
e934d3ab2e Show number for search results when holding down command key
The number appears after command has been held down for 0.2 seconds and is meant as a hint about being able to press ⌘1-n to jump to the n’th file with matches.
2014-10-19 20:26:00 +02:00
Allan Odgaard
e22651f9d8 Add replace button to find dialog 2014-10-18 13:38:11 +02:00
Allan Odgaard
9c9de99418 Verify checksum when replacing in non-open documents
If the checksum does not match we simply skip the document and does not show the replacement as having been done (in the UI).
2014-10-18 13:03:01 +02:00
Allan Odgaard
053b08456f Use a real content checksum when doing folder searching 2014-10-18 13:03:01 +02:00
Allan Odgaard
207c642614 Use number formatter for all numbers in search dialog 2014-10-17 15:28:03 +02:00
Allan Odgaard
7bdbc4985a Clear search marks from documents if removed from search results 2014-10-15 17:08:19 +02:00
Allan Odgaard
c672759acb Improve handling of replacement previews
We no longer do any reloading of the outline view (on changes) and we have the item store the replacement string when a replacement has been done, so that it will continue to show the actual replacement done (after replacement string is changed).
2014-10-15 17:02:22 +02:00
Allan Odgaard
aa18a55b20 Remove performedReplaceAll property
This only served to disable the Replace All button, we now rely solely on the number of non-excluded and non-ignored results to control the enabled state of the button.
2014-10-15 17:02:22 +02:00
Allan Odgaard
63207a960c Rely on the ‘ignored’ property for whether replacements are done
We now bind the enabled state of the “exclude result” checkbox to this property and only set it to YES for files that had replacements done, meaning that the checkboxes are available after replace for files that weren’t involved in the replacement.
2014-10-15 17:02:22 +02:00
Allan Odgaard
33c9a2b919 Check if all matches are excluded before iterating through them 2014-10-15 17:02:21 +02:00
Allan Odgaard
8de8291afe Add ignored property to FFResultNode
When a group node is ignored then it report all its children as excluded regardless of their actual state. It is still possible to query the children for the real state.
2014-10-15 17:02:21 +02:00
Allan Odgaard
e2ab281343 Define excluded property for FFResultNode child nodes
This returns YES when all leafs are excluded.
2014-10-15 15:37:07 +02:00
Allan Odgaard
4f807fd109 Make countOfLeafs/Excluded a readonly property 2014-10-15 15:35:54 +02:00
Allan Odgaard
826437a2ef Introduce constant for search mark identifier 2014-10-15 10:28:18 +02:00