256 Commits

Author SHA1 Message Date
Allan Odgaard
28533a48d6 Ignore binary identification glob when search should include binary files 2016-06-22 19:45:24 +02:00
Allan Odgaard
f5832c975f Add missing include statements 2016-06-22 18:31:49 +02:00
Allan Odgaard
bc20f67d05 Revert "Search results are now added in batch to limit KVO notifications"
This was published by mistake as 8175d2d9d8 address the same problem but with less complex code.

This reverts commit f7edb51ea3.
2016-06-19 22:08:36 +02:00
Ronald Wampler
e452a5ee55 Move "Go to Tab" to the Window menu and rename to "Select Tab"
Also edit the source to reflect the change in name (e.g., `updateGoToMenu:` → `updateSelectTabMenu:`).
2016-06-19 08:45:16 +02:00
Allan Odgaard
45a23472cb Use localized number formatting for collapsed search result headers 2016-06-18 12:15:32 +02:00
Allan Odgaard
b232a70d69 Remove countOfLeafs property from OakSearchResultsHeaderCellView 2016-06-18 12:15:32 +02:00
Allan Odgaard
f7edb51ea3 Search results are now added in batch to limit KVO notifications
Majority of the time in the main thread was spent updating the countOfLeafs property since canReplaceAll and the result text are dependent on this property.
2016-06-18 12:15:32 +02:00
Allan Odgaard
3346f8e237 Use operator== from document_t instead of its identifier’s
This serves to make the code slightly more abstract and allows the document to optimize the comparison operator, e.g. testing pointer equivalence before involving more complex checks.
2016-06-18 11:29:13 +02:00
Allan Odgaard
8175d2d9d8 Do not observe count of matches until search has completed
We do not display this counter during the search but triggering a KVO notification for each search result has a noticeable overhead and can result in unresponsive UI when the number of results are in the hundreds of thousands.
2016-06-18 11:29:05 +02:00
Allan Odgaard
994f3538f5 Clear old search results in setDocumentSearch:
That we have an empty results array is a prerequisite for starting a document search, so we should do it in the method itself.
2016-06-18 10:34:49 +02:00
Allan Odgaard
c0637c1037 Fix issue with “one file searched” format string
When using $n in a format string placeholder for n > 1 then we must also include $n-1.
2016-06-16 20:04:26 +02:00
Allan Odgaard
258e5449f1 Improve folder search performance
This relates to documents with many matches on the same (long) line.

Previously we would search for “end of line” per match found, which for a single-line document was effectively quadratic time complexity.

Furthermore we would make a string copy of the entire line for every match. This is now limited to 500 bytes (or longer if the match requires it) with the context before the match being up to 150 bytes (it’s using modulo so adjacent matches should generally show context starting from the same offset).

The test case for the optimization was a 3MB file with only 2 lines and 150,000 matches. After this commit the results are presented in about two seconds (Macbook Pro). Not impressive but much better than before :)
2016-06-16 20:04:21 +02:00
Allan Odgaard
99de97f976 Use document_t’s visitor API for folder search 2016-06-13 13:02:50 +02:00
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