Skip to content
Open
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
39 changes: 37 additions & 2 deletions addons/script-ide/split/split_code_edit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
extends CodeEdit

var last_v_scroll: float
var pause_text_changed = false

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use types always. : bool


func _ready() -> void:
editable = false
editable = true
caret_draw_when_editable_disabled = true
set_v_scroll.call_deferred(last_v_scroll)
set_v_scroll.call_deferred(last_v_scroll)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty space at the end


static func new_from(from_code_edit: CodeEdit) -> CodeEdit:
var new_code_edit: CodeEdit = new()

if not from_code_edit.tree_exiting.is_connected(new_code_edit.exit_tree.bind(new_code_edit)):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the ! instead of not

from_code_edit.tree_exiting.connect(new_code_edit.exit_tree.bind(new_code_edit))

new_code_edit.text = from_code_edit.text
new_code_edit.set_caret_line(from_code_edit.get_caret_line())
if not new_code_edit.text_changed.is_connected(new_code_edit.to_changed.bind(from_code_edit,new_code_edit)):
new_code_edit.text_changed.connect(new_code_edit.to_changed.bind(from_code_edit,new_code_edit))
if not from_code_edit.text_changed.is_connected(new_code_edit.from_changed.bind(from_code_edit,new_code_edit)):
from_code_edit.text_changed.connect(new_code_edit.from_changed.bind(from_code_edit,new_code_edit))

new_code_edit.syntax_highlighter = from_code_edit.syntax_highlighter
new_code_edit.highlight_all_occurrences = from_code_edit.highlight_all_occurrences
new_code_edit.highlight_current_line = from_code_edit.highlight_current_line
Expand Down Expand Up @@ -45,3 +55,28 @@ static func new_from(from_code_edit: CodeEdit) -> CodeEdit:
new_code_edit.last_v_scroll = from_code_edit.scroll_vertical

return new_code_edit

func from_changed(from:CodeEdit,to:CodeEdit) -> void:
if not pause_text_changed:
pause_text_changed = true
var pos = to.get_caret_line()
var scroll = to.scroll_vertical
to.text = from.text
to.set_caret_line(pos)
to.scroll_vertical = scroll
pause_text_changed = false

func to_changed(from:CodeEdit,to:CodeEdit) -> void:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always leave an empty space after the :, e.g. from: CodeEdit

if not pause_text_changed:
pause_text_changed = true
var pos = from.get_caret_line()
var scroll = from.scroll_vertical
from.text = to.text
from.set_caret_line(pos)
from.scroll_vertical = scroll
pause_text_changed = false

func exit_tree(to:CodeEdit) -> void:
if to:
to.get_parent().remove_child(to)
to.queue_free()