mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that the original file format should be retained when saving the same file in SQL editor. Fixes #3767
This commit is contained in:
committed by
Akshay Joshi
parent
87d08de3a0
commit
43e127de31
@@ -1250,10 +1250,20 @@ def save_file():
|
||||
file_path.lstrip('/').lstrip('\\')
|
||||
)
|
||||
|
||||
# Get value for encoding if file is already loaded to SQL editor
|
||||
def get_file_encoding_of_loaded_file(file_name):
|
||||
encoding = 'utf-8'
|
||||
for ele in Filemanager.loaded_file_encoding_list:
|
||||
if file_name in ele:
|
||||
encoding = ele[file_name]
|
||||
return encoding
|
||||
|
||||
enc = get_file_encoding_of_loaded_file(os.path.basename(file_path))
|
||||
|
||||
if hasattr(str, 'decode'):
|
||||
file_content = file_data['file_content']
|
||||
else:
|
||||
file_content = file_data['file_content'].encode()
|
||||
file_content = file_data['file_content'].encode(enc)
|
||||
|
||||
# write to file
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user