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

Qt: handle newlines in TextBuffer print() #3314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ahigerd
Copy link
Contributor

@ahigerd ahigerd commented Oct 12, 2024

User "Wombat" observed that printing strings containing newlines into a text buffer would word-wrap as if the newlines weren't there. Turns out, ScriptingTextBuffer::print() just wasn't handling newlines at all. This PR causes print() to split the input on newlines and add each section as a separate line in the document.

@ahigerd ahigerd changed the title Scripting: handle newlines in TextBuffer print() Qt: handle newlines in TextBuffer print() Oct 12, 2024
if (!m_shim.cursor.atBlockEnd()) {
m_shim.cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
for (QString split : text.split('\n')) {
m_shim.cursor.beginEditBlock();
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be outside the loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so? We want to create a new block for each line being inserted, don't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. Actually, reading the docs, why do you even need this? You don't support undo/redo in text buffers and that's all this does.

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

Successfully merging this pull request may close these issues.

2 participants