Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TextEdit option to prevent copying without a selection #90743

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

timothyqiu
Copy link
Member

Closes godotengine/godot-proposals#9527

Copying current line if nothing is selected is a common code editor feature. But it's usually not expected in normal multiline input boxes. So this behavior should be optional for TextEdit.

This option affects both copying and cutting. Name resembles editor.emptySelectionClipboard in VS Code.

  • Adds empty_selection_clipboard_enabled to TextEdit.
  • Adds text_editor/behavior/general/empty_selection_clipboard to Editor Settings.

@timothyqiu timothyqiu requested review from a team as code owners April 16, 2024 09:46
@AThousandShips AThousandShips added this to the 4.x milestone Apr 16, 2024
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
@timothyqiu timothyqiu force-pushed the empty-selection-clipboard branch from c5beb9d to 9b1e1f7 Compare April 17, 2024 03:29
@timothyqiu timothyqiu force-pushed the empty-selection-clipboard branch from 9b1e1f7 to b5a32d3 Compare May 5, 2024 08:58
Copy link
Contributor

@kitbdev kitbdev left a comment

Choose a reason for hiding this comment

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

Maybe we should have a test for it, for copy and cut in test_text_edit and for cut in test_code_edit.

Comment on lines +7009 to +7232
if (!empty_selection_clipboard_enabled) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably needed in CodeEdit::_cut_internal as well so it doesn't delete empty lines that aren't copied.

@timothyqiu timothyqiu force-pushed the empty-selection-clipboard branch from b5a32d3 to bf1d06c Compare September 13, 2024 01:59
@timothyqiu timothyqiu requested a review from a team as a code owner September 13, 2024 01:59
@timothyqiu
Copy link
Member Author

Added tests and fixed cut behavior in CodeEdit.

@timothyqiu timothyqiu force-pushed the empty-selection-clipboard branch from bf1d06c to 504e065 Compare September 14, 2024 01:40
Copy link
Member

@Geometror Geometror left a comment

Choose a reason for hiding this comment

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

Works great! (expected behavior with both single and multicaret editing)
Code looks fine too.

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Sep 23, 2024
@akien-mga akien-mga merged commit 720c236 into godotengine:master Sep 23, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add text editor option to prevent copying current line without a selection
5 participants