mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
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.
This commit is contained in:
@@ -1007,13 +1007,15 @@ namespace document
|
||||
|
||||
void select_charset (std::string const& path, io::bytes_ptr content, file::open_context_ptr context)
|
||||
{
|
||||
if(_try_disk_encoding)
|
||||
if(_encoding_state == kEncodingUseDisk)
|
||||
{
|
||||
_try_disk_encoding = false;
|
||||
_encoding_state = kEncodingTestProbability;
|
||||
context->set_charset(_document->_disk_encoding);
|
||||
}
|
||||
else
|
||||
else if(_encoding_state == kEncodingTestProbability)
|
||||
{
|
||||
_encoding_state = kEncodingUseFallback;
|
||||
|
||||
encoding::classifier_t db;
|
||||
static std::string const kEncodingFrequenciesPath = path::join(path::home(), "Library/Caches/com.macromates.TextMate/EncodingFrequencies.binary");
|
||||
db.load(kEncodingFrequenciesPath);
|
||||
@@ -1025,6 +1027,16 @@ namespace document
|
||||
context->set_charset(probabilities.begin()->second);
|
||||
else context->set_charset("ISO-8859-1");
|
||||
}
|
||||
else if(_encoding_state == kEncodingUseFallback)
|
||||
{
|
||||
_encoding_state = kEncodingAbort;
|
||||
context->set_charset("WINDOWS-1252");
|
||||
}
|
||||
else
|
||||
{
|
||||
crash_reporter_info_t info("unknown encoding");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void select_line_feeds (std::string const& path, io::bytes_ptr content, file::open_context_ptr context) { context->set_line_feeds(_document->_disk_newlines); }
|
||||
@@ -1079,7 +1091,7 @@ namespace document
|
||||
|
||||
private:
|
||||
document::document_ptr _document;
|
||||
bool _try_disk_encoding = true;
|
||||
enum { kEncodingUseDisk, kEncodingTestProbability, kEncodingUseFallback, kEncodingAbort } _encoding_state = kEncodingUseDisk;
|
||||
bool _wait;
|
||||
cf::run_loop_t _run_loop;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user