Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/autoload/State.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func sync_stable_editor_markup() -> void:
if not stable_editor_markup.is_empty():
apply_markup(stable_editor_markup, true)

func sync_stable_export_markup() -> void:
if not stable_export_markup.is_empty():
apply_markup(stable_export_markup, true)

func apply_markup(markup: String, is_edit: bool) -> void:
var svg_parse_result := SVGParser.markup_to_root(markup)
last_parse_error = svg_parse_result.error
Expand Down
2 changes: 2 additions & 0 deletions src/config_classes/SaveData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,8 @@ func get_palette(idx: int) -> Palette:
emit_changed()
if not export_formatter.changed.is_connected(emit_changed):
export_formatter.changed.connect(emit_changed)
if not export_formatter.changed_deferred.is_connected(State.sync_stable_export_markup):
export_formatter.changed_deferred.connect(State.sync_stable_export_markup)


@export var default_optimizer: Optimizer = null:
Expand Down
10 changes: 4 additions & 6 deletions src/config_classes/TabData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func _init(new_id := -1) -> void:
super()

func _connect_to_export_formatter_change() -> void:
Configs.savedata.export_formatter.changed.connect(_save_svg_text)
Configs.savedata.export_formatter.changed_deferred.connect(_save_svg_text)

func get_edited_file_path() -> String:
return get_edited_file_path_for_id(id)
Expand Down Expand Up @@ -147,11 +147,9 @@ func _sync() -> void:
marked_unsaved = false
else:
var edited_text_parse_result := SVGParser.markup_to_root(FileAccess.get_file_as_string(get_edited_file_path()))
var file_text := FileAccess.get_file_as_string(svg_file_path)
if edited_text_parse_result.error == SVGParser.ParseError.OK:
marked_unsaved = (file_text != SVGParser.root_to_export_markup(edited_text_parse_result.svg))
else:
marked_unsaved = (file_text != FileAccess.get_file_as_string(get_edited_file_path()))
var text_to_compare := SVGParser.root_to_export_markup(edited_text_parse_result.svg) if\
(edited_text_parse_result.error == SVGParser.ParseError.OK) else FileAccess.get_file_as_string(get_edited_file_path())
marked_unsaved = (FileAccess.get_file_as_string(svg_file_path) != text_to_compare)

elif not FileAccess.file_exists(get_edited_file_path()) or SVGParser.markup_check_is_root_empty(get_true_svg_text()):
empty_unsaved = true
Expand Down