From b3440462922997593847dc583465424d6344bc5c Mon Sep 17 00:00:00 2001 From: rekols Date: Mon, 17 Sep 2018 21:13:40 +0800 Subject: [PATCH] fix: goto next & previous word. Change-Id: I14d3740f8ad2bbf85bce87e8285c06454556fb49 --- editor/resource/settings.json | 12 ++++++------ editor/src/texteditor.cpp | 12 ++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/editor/resource/settings.json b/editor/resource/settings.json index daddb353..41fc6e93 100644 --- a/editor/resource/settings.json +++ b/editor/resource/settings.json @@ -212,13 +212,13 @@ "key": "forwardword", "name": "Forward word", "type": "shortcut", - "default": "Alt+Right" + "default": "Ctrl+Right" }, { "key": "backwardword", "name": "Backward word", "type": "shortcut", - "default": "Alt+Left" + "default": "Ctrl+Left" }, { "key": "nextline", @@ -634,13 +634,13 @@ "key": "forwardword", "hide" : true, "reset" : false, - "default": "Alt+Right" + "default": "Ctrl+Right" }, { "key": "backwardword", "hide" : true, "reset" : false, - "default": "Alt+Left" + "default": "Ctrl+Left" }, { "key": "nextline", @@ -1526,13 +1526,13 @@ "key": "forwardword", "hide" : true, "reset" : false, - "default": "Alt+Right" + "default": "Ctrl+Right" }, { "key": "backwardword", "hide" : true, "reset" : false, - "default": "Alt+Left" + "default": "Ctrl+Left" }, { "key": "nextline", diff --git a/editor/src/texteditor.cpp b/editor/src/texteditor.cpp index e2e0ff36..abedda1b 100644 --- a/editor/src/texteditor.cpp +++ b/editor/src/texteditor.cpp @@ -206,9 +206,11 @@ void TextEditor::forwardWord() QTextCursor cursor = textCursor(); if (m_cursorMark) { - cursor.setPosition(getNextWordPosition(cursor, QTextCursor::KeepAnchor), QTextCursor::KeepAnchor); + // cursor.setPosition(getNextWordPosition(cursor, QTextCursor::KeepAnchor), QTextCursor::KeepAnchor); + cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); } else { - cursor.setPosition(getNextWordPosition(cursor, QTextCursor::MoveAnchor), QTextCursor::MoveAnchor); + // cursor.setPosition(getNextWordPosition(cursor, QTextCursor::MoveAnchor), QTextCursor::MoveAnchor); + cursor.movePosition(QTextCursor::NextWord, QTextCursor::MoveAnchor); } setTextCursor(cursor); @@ -219,9 +221,11 @@ void TextEditor::backwardWord() QTextCursor cursor = textCursor(); if (m_cursorMark) { - cursor.setPosition(getPrevWordPosition(cursor, QTextCursor::KeepAnchor), QTextCursor::KeepAnchor); + // cursor.setPosition(getPrevWordPosition(cursor, QTextCursor::KeepAnchor), QTextCursor::KeepAnchor); + cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); } else { - cursor.setPosition(getPrevWordPosition(cursor, QTextCursor::MoveAnchor), QTextCursor::MoveAnchor); + // cursor.setPosition(getPrevWordPosition(cursor, QTextCursor::MoveAnchor), QTextCursor::MoveAnchor); + cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor); } setTextCursor(cursor);