Commit Graph

97 Commits

Author SHA1 Message Date
Allan Odgaard
e81286b0cd Remove unused include 2014-05-16 22:11:28 +07:00
Allan Odgaard
af3f4aaa33 Check result of most CF/CT ‘Create’ functions 2014-05-15 13:17:30 +07:00
Allan Odgaard
9a80fd4226 Fix potential stall using “save all” from find in folder
This would happen if the user manually saved one of the documents with replacements before invoking save all, since the wrong “did save” callback was called when trying to save an unmodified document.
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
86a5538992 Ensure server object is alive when client is destroyed 2014-04-12 20:33:30 +07:00
Allan Odgaard
375893fc7f Add a ‘did change content’ notification to document_t
This is only meant for when the document reloads content because the file was changed on disk. Long-term though, I think reloading document because of disk changes should be handled at a higher level.
2014-04-12 11:23:07 +07:00
Allan Odgaard
1452148a65 Run in default run-loop mode for document_t::sync_open 2014-04-12 11:22:53 +07:00
Allan Odgaard
e379021492 Assert that we are not blocking the main queue 2014-04-11 10:57:09 +07:00
Allan Odgaard
aaabfd2e26 Use custom test system for testing the ‘document’ framework 2014-04-08 15:43:21 +07:00
Allan Odgaard
e974582baa Allow specifying run-loop mode for document_t::sync_open 2014-04-08 15:43:20 +07:00
Allan Odgaard
3642ee2750 Save All from find window uses default run-loop mode for saving
When saving and the document needs to execute a command (e.g. callback.document.export) then we can no longer use our special run-loop mode, as command execution is now using queues, and queue dispatching is paused when running in a custom run-loop mode.
2014-04-07 17:29:49 +07:00
Allan Odgaard
6cc0108961 Rename document_t:{open,save} → document_t:sync_{open,save}
This makes it easier to search for code that use these functions.
2014-04-07 17:28:41 +07:00
Allan Odgaard
6b24c1b11f Missing broadcast when changing “on disk” in document_t::set_path
This resulted in missing proxy icon update e.g. when saving an untitled document over an existing one, as we would first set the path to the new location (and indirectly change the “is on disk” status without sending the proper notification).
2014-04-05 14:13:40 +07:00
Allan Odgaard
172d2d41c9 Ensure the com.macromates.visibleIndex attribute value is valid
Also skip checking for saved selection / visible index if there is no text in the buffer (since in this case, teh only valid values for seleciton / visible index are the default values).
2014-04-05 14:13:39 +07:00
Allan Odgaard
7f7613fe62 Change io::create_pipe API
We now return a tuple and always set FD_CLOEXEC.
2014-03-29 09:57:09 +07:00
Allan Odgaard
935da75a43 Use new path::temp API to set initial content 2014-03-28 19:31:15 +07:00
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
5bbbed72e5 Saving file with missing parent asks if it should be created 2013-12-14 14:37:55 +07:00
Allan Odgaard
94230858f8 Abort if unable to reload document
This should be handled better, but previously we would crash due to filling the stack, so better to just immediately abort when we detect the problem, so that we get a better crash report and can see how widespread the issue is.
2013-10-19 23:34:41 +02:00
Allan Odgaard
9b57695a5c Use file::reader_t for folder search 2013-10-08 21:59:56 +02:00
Allan Odgaard
bf09650c0b Reload file using most probable charset when it changes on disk
Previously if the file had been loaded as ASCII/UTF-8 and was changed on disk to something other than UTF-8, TextMate would go into infinite loop (retrying with UTF-8). It now uses the encoding classifier to find the most probable encoding (based on learned frequencies) falling back on ISO-8859-1, if there is no candidate.

Ideally it would bring up a warning, informing the user of the problem and allowing a manual correction of character set.

Fixes #1073.
2013-10-05 14:32:36 +02:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
80e26b1faa Don’t dereference end-of-range iterator 2013-08-27 15:30:09 +02:00
Allan Odgaard
15a15e8c15 Remove prototype for unimplemented member function 2013-08-24 01:19:29 +02:00
Allan Odgaard
a52165694c Move crash reporter info support to own framework
This is to avoid cyclic dependencies since it was previously in a somewhat high-level framework, so everything that framework depended on, could not augment crash reports.
2013-08-12 19:32:23 +02:00
Allan Odgaard
2c0010a141 Restore “first visible character” instead of visible rectangle
This is when switching tabs ore re-opening a file.

Restoring the visible rectangle doesn’t always work because we do an initial heuristic layout where we don’t do proper soft wrap and may also lack scoped settings to increase font size for headings, meaning that the restored visible rectangle does not point to the same section of the text, as it would with a fully updated layout.

This fixes #243.
2013-08-04 14:36:45 +02:00
Allan Odgaard
9072ba8d26 Collect info related to potential crash 2013-07-31 18:42:31 +02:00
Allan Odgaard
1d4d3bd3d3 Fix path/inode lookup when opening documents
The strategy is to prefer an existing document with same path and if there is none, check if there is a document with the same inode. The latter is so that links or files that have been moved, do not create duplicate documents.

The old code used a single map for the lookup, using path::identifier_t as key (wrapping path and/or inode), though since the map is ordered, the code would occasionally fail, as the keys cannot be correctly ordered (so effectively this reworked code is a fix for an incorrect path::identifier_t::operator<).

Fixes #1052.
2013-07-30 15:34:17 +02:00
Allan Odgaard
a4a2af726a Use std::mutex instead of OSSpinLock 2013-07-30 15:34:17 +02:00
Allan Odgaard
e0e7059500 Limit use of path::identifier_t 2013-07-30 15:34:17 +02:00
Allan Odgaard
b09d1974ea Improve speed of stopping the document scanner
Closes #1069.
2013-07-29 16:24:29 +02:00
Allan Odgaard
0a64d372a9 Improve lstat error message 2013-07-29 16:07:33 +02:00
Allan Odgaard
24bd109ccc Store tab size with backups 2013-07-29 16:06:15 +02:00
Allan Odgaard
05efb628b4 Setup indent settings at a higher level
We now setup the indent settings when creating untitled documents where we know the folder, so that we can use potential settings scoped to that folder.

Since the document itself no longer sets this as part of regular buffer setup, we also set it when opening a document with a path, and when changing a document’s file type, although the latter is probably temporary.

Closes #305.
2013-07-29 15:50:31 +02:00
Allan Odgaard
a05088f9be Document from content now sets file type and tab settings
Presently we also set file type (and thus indirectly indent settings) when “opening” a document, but I wish to remove that code, so that one can create a document, set all desired settings, and not worry about later code overwriting these settings.
2013-07-29 13:56:15 +02:00
Allan Odgaard
ad44540209 Use document’s indent accessor instead of going via buffer() 2013-07-29 12:43:37 +02:00
Allan Odgaard
2ad22d7662 Add indent accessor to document_t 2013-07-29 10:11:51 +02:00
Allan Odgaard
98585e166e Use byte range for replacement API 2013-07-27 16:30:02 +02:00
Allan Odgaard
db070efed8 Replace after a folder search now use the decoded content
This wasn’t a problem before, as we didn’t decode the content prior to doing a folder search.
2013-07-27 16:28:44 +02:00
Allan Odgaard
8094d61ec4 Only open documents that are already open (during save)
The “find in folder” will create documents, set their content, and potentially save them.

If a document is not open, it should save it without going through the content examination for file type and similar, which is part of opening a non-open document.
2013-07-27 12:26:49 +02:00
Allan Odgaard
7ed6199df1 Print error if scandir/lstat fails 2013-07-26 16:26:20 +02:00
Jasmin Lapalme
b9a06b3e0a Support UTF-16/32 and user fallback encoding for folder search
The fallback encoding is taken from .tm_properties (attr.unknown-encoding).
2013-07-26 13:53:57 +02:00
Allan Odgaard
491fc8a3e3 Add missing semi-colons after assertion 2013-07-21 13:25:28 +02:00
Allan Odgaard
2c307cabce Allow setting a tab as “sticky”
Presently this can only be done by right-clicking the tab and selecting the “Sticky” option — if a tab is sticky then it will not be closed when executing any of the batch close actions (Close All Tabs, Close Other Tabs, Close Tabs to the Right, and holding option down while opening a file via file browser or file chooser).

Closes #1038.
2013-07-21 13:25:28 +02:00
Allan Odgaard
1b61c9c688 Fix “unused variable” compiler warning 2013-07-21 13:25:27 +02:00
Allan Odgaard
d22f7163c5 Ensure tab size read from .tm_properties is larger than zero
Closes #1028.
2013-06-21 01:43:42 +07:00
Allan Odgaard
6ee93431bc Avoid passing -1 (as fd) to kevent() and close()
Observing paths will normally fail when opening files that only privileged users can read.
2013-06-15 16:05:48 +07:00
Allan Odgaard
e0523bb926 Improve encapsulation 2013-05-16 21:36:49 +07:00
Allan Odgaard
b6fce5fe30 Check if command result is valid UTF-8
This was previously implicit by using oak::command_t
2013-05-16 21:36:43 +07:00