mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
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.
This commit is contained in:
@@ -395,7 +395,7 @@ namespace
|
||||
_state = kStateIdle;
|
||||
_next_state = kStateHarmonizeLineFeeds;
|
||||
|
||||
_encoding.set_newlines(text::estimate_line_endings(_content->begin(), _content->end()));
|
||||
_encoding.set_newlines(text::estimate_line_endings(_content->begin(), _content->end(), NULL_STR));
|
||||
proceed();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace text
|
||||
// =====================
|
||||
|
||||
template <typename _InputIter>
|
||||
std::string estimate_line_endings (_InputIter const& first, _InputIter const& last)
|
||||
std::string estimate_line_endings (_InputIter const& first, _InputIter const& last, std::string const& fallback = kLF)
|
||||
{
|
||||
size_t const kEnoughSamples = 50;
|
||||
|
||||
@@ -49,7 +49,9 @@ namespace text
|
||||
return kCRLF;
|
||||
else if(lf_count == 0 && crlf_count == 0 && cr_count > 0)
|
||||
return kCR;
|
||||
return kLF;
|
||||
else if(lf_count != 0)
|
||||
return kLF;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
template <typename _InputIter>
|
||||
|
||||
Reference in New Issue
Block a user