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

Unexpected behavior of "Delete Word" (Ctrl+Backspace) #453

Closed
dwu opened this Issue Jan 3, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@dwu
Contributor

dwu commented Jan 3, 2017

Probably more of a question than an issue. The behavior of "Delete word" as currently implemented differs quite a bit from that in other editors/word processors (tested in Emacs, Kate, LibreOffice Writer, SublimeText).

Hitting Ctrl+Backspace and being used to the common behavior sometimes leads to -- at least for me -- unexpected results. I'm however not sure whether this is just a personal preference of mine or whether it might be confusing to other people as well.

Here are some examples. ^ denotes the character where the cursor is positioned before "Delete Word" is triggered.

Scenario 1

Before:

abcd efgh ijkl
          ^

QOwnNotes after:

abcd efgh 
          ^

Other editors after:

abcd ijkl
     ^

Scenario 2

Before:

abcd efgh ijkl
       ^

QOwnNotes after:

abcd  ijkl
     ^

Other editors after:

abcd gh ijkl
     ^

Experimenting a bit with the current implementation of on_actionDelete_word_triggered here's a proof-of-concept that seems to match my personal expectation of Ctrl+Backspace best:

/**
 * Deletes the selection if text is selected and 
 * - the previous word if cursor is not within word boundaries
 * - to the previous word boundary if cursor is within word boundaries
 * when no text is selected.
 */
void MainWindow::on_actionDelete_word_triggered() {
    QTextCursor cursor = activeNoteTextEdit()->textCursor();
    if (cursor.selectedText().isEmpty()) {
        cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
    }
    cursor.removeSelectedText();
}

Is the current behavior a deliberate decision? If not, would you be open to adapting it to match the behavior of other editors?

@pbek

This comment has been minimized.

Owner

pbek commented Jan 3, 2017

I like that you are implementing your own proposals! 👍 😄
And I like your proposal and your implementation of it, thanks a lot!

17.01.0

  • the Delete word functionality now matches that of other editors more closely (thank you @dwu)

@pbek pbek added the enhancement label Jan 3, 2017

@pbek pbek added this to the 17.01.0 milestone Jan 3, 2017

@pbek

This comment has been minimized.

Owner

pbek commented Jan 3, 2017

There now is a new release, could you please test it and report if it works for you?

@dwu

This comment has been minimized.

Contributor

dwu commented Jan 3, 2017

Tested and working fine. Thanks!

@dwu dwu closed this Jan 3, 2017

@pbek

This comment has been minimized.

Owner

pbek commented Jan 3, 2017

Thank you for testing!

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