mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
If file is not on disk, use tmProperties for encoding
This happens e.g. if we do ‘ls|mate’ — here we do have content which got a charset and newline mode assigned during “load”, but from the user’s POV he is saving a new file (if he saves the buffer) so should get his configured encoding.
This commit is contained in:
@@ -647,14 +647,17 @@ namespace document
|
||||
encoding::type document_t::encoding_for_save_as_path (std::string const& path)
|
||||
{
|
||||
encoding::type res = disk_encoding();
|
||||
if(res.charset() != kCharsetNoEncoding && res.newlines() != NULL_STR)
|
||||
return res;
|
||||
|
||||
settings_t const& settings = settings_for_path(path);
|
||||
if(res.charset() == kCharsetNoEncoding)
|
||||
if(!is_on_disk() || res.charset() == kCharsetNoEncoding)
|
||||
{
|
||||
res.set_charset(settings.get(kSettingsEncodingKey, kCharsetUTF8));
|
||||
if(res.newlines() == NULL_STR)
|
||||
res.set_byte_order_mark(settings.get(kSettingsUseBOMKey, res.byte_order_mark()));
|
||||
}
|
||||
|
||||
if(!is_on_disk() || res.newlines() == NULL_STR)
|
||||
res.set_newlines(settings.get(kSettingsLineEndingsKey, "\n"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user