D7660: Fix a regression caused by changing backspace key behavior

Anthony Fieroni noreply at phabricator.kde.org
Wed Oct 11 12:01:34 UTC 2017


anthonyfieroni added inline comments.

INLINE COMMENTS

> katedocument.cpp:3169-3223
>          if (!(config()->backspaceIndents())) {
>              // ordinary backspace
> -            KTextEditor::Cursor beginCursor(line, view->textLayout(c)->previousCursorPosition(c.column()));
> +            KTextEditor::Cursor beginCursor(line, 0);
>              KTextEditor::Cursor endCursor(line, col);
> -
> +            if (!view->config()->backspaceRemoveComposed()) { // Normal backspace behavior
> +                // move to left of surrogate pair
> +                if (!isValidTextPosition(beginCursor)) {

This peace of code should be simplified, to not have code dublication.

  if (config()->backspaceIndents()) {
       // backspace indents: erase to next indent position
        Kate::TextLine textLine = m_buffer->plainLine(line);
  
        // don't forget this check!!!! really!!!!
        if (!textLine) {
            return;
        }
  
        int colX = textLine->toVirtualColumn(col, config()->tabWidth());
        int pos = textLine->firstChar();
        if (pos > 0) {
            pos = textLine->toVirtualColumn(pos, config()->tabWidth());
        }
  
        if (pos < 0 || pos >= (int)colX) {
            // only spaces on left side of cursor
            indent(KTextEditor::Range(line, 0, line, 0), -1);
        }
  }

Then validate pos and add 2 backspace behaviors.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D7660

To: safaalfulaij, #ktexteditor, jgrulich, hein, dhaumann
Cc: anthonyfieroni, cullmann, jgrulich, dhaumann, hein, kwrite-devel, #frameworks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kwrite-devel/attachments/20171011/1ee1fc8e/attachment.html>


More information about the KWrite-Devel mailing list