diff --git a/src/dialog/vupdater.cpp b/src/dialog/vupdater.cpp index 21082c0a..715763c1 100644 --- a/src/dialog/vupdater.cpp +++ b/src/dialog/vupdater.cpp @@ -99,27 +99,34 @@ void VUpdater::checkUpdates() } // Return if @p_latestVersion is newer than p_curVersion. -// They are both in format xx.xx +// They are both in format xx.xx.xx.xx bool isNewerVersion(const QString &p_curVersion, const QString &p_latestVersion) { QStringList curList = p_curVersion.split('.', QString::SkipEmptyParts); QStringList latestList = p_latestVersion.split('.', QString::SkipEmptyParts); - if (curList.size() != 2 || latestList.size() != 2) { - return false; + int i = 0; + for (; i < curList.size() && i < latestList.size(); ++i) { + int a = curList[i].toInt(); + int b = latestList[i].toInt(); + + if (a > b) { + return false; + } else if (a < b) { + return true; + } } - int a = curList[0].toInt(); - int b = curList[1].toInt(); - int c = latestList[0].toInt(); - int d = latestList[1].toInt(); - if (a > c) { + if (i < curList.size()) { + // 1.2.1 vs 1.2 return false; - } else if (a < c) { + } else if (i < latestList.size()) { + // 1.2 vs 1.2.1 return true; } else { - return d > b; + // 1.2 vs 1.2 + return false; } } diff --git a/src/resources/docs/shortcuts_en.md b/src/resources/docs/shortcuts_en.md index 57d7eaf3..6eb7bb19 100644 --- a/src/resources/docs/shortcuts_en.md +++ b/src/resources/docs/shortcuts_en.md @@ -1,6 +1,6 @@ # VNote Shortcuts 1. All the keys without special notice are **case insensitive**; -2. On macOS, `Ctrl` corresponds to `Command`; +2. On macOS, `Ctrl` corresponds to `Command` except in Vim mode. ## Normal Shortcuts - `Ctrl+E E` @@ -115,7 +115,7 @@ Display shortcuts documentation. ## Navigation Mode Within the Captain MOde, `W` will turn VNote into **Navigation Mode**. In this mode, VNote will display at most two characters on some major widgets, and then pressing corresponding characters will jump to that widget. -## Vim Mode +# Vim Mode VNote supports a simple but useful Vim mode, including **Normal**, **Insert**, **Visual**, and **VisualLine** modes. VNote supports following features of Vim: @@ -124,7 +124,7 @@ VNote supports following features of Vim: - Marks `a-z`; - Registers `"`, `_`, `+`, `a-z`(`A-Z`); - Jump locations list (`Ctrl+O` and `Ctrl+I`); -- Leader key +- Leader key (`Space`) - Currently `y/d/p` equals to `"+y/d/p`, which will access the system's clipboard. - `zz`, `zb`, `zt`; - `u` and `Ctrl+R` for undo and redo; diff --git a/src/resources/docs/shortcuts_zh.md b/src/resources/docs/shortcuts_zh.md index 250d789f..ec4dac83 100644 --- a/src/resources/docs/shortcuts_zh.md +++ b/src/resources/docs/shortcuts_zh.md @@ -1,6 +1,6 @@ # VNote快捷键说明 1. 以下按键除特别说明外,都不区分大小写; -2. 在macOS下,`Ctrl`对应于`Command`; +2. 在macOS下,`Ctrl`对应于`Command`,在Vim模式下除外。 ## 常规快捷键 - `Ctrl+E E` @@ -115,7 +115,7 @@ ## 展览模式 在舰长模式中,`W`命令会进入 **展览模式**。在展览模式中,VNote会在常用的主要部件上显示至多两个字母,此时输入对应的字母即可跳转到该部件中,从而实现快速切换焦点并触发功能。 -## Vim Mode +# Vim Mode VNote支持一个简单但有用的Vim模式,包括 **正常**, **插入**, **可视**, **可视行** 模式。 VNote支持以下几个Vim的特性: @@ -124,7 +124,7 @@ VNote支持以下几个Vim的特性: - 标记 `a-z`; - 寄存器 `"`, `_`, `+`, `a-z`(`A-Z`); - 跳转位置列表 (`Ctrl+O` and `Ctrl+I`); -- 前导键 +- 前导键 (`Space`) - 目前 `y/d/p` 等同于 `"+y/d/p`, 从而可以访问系统剪切板。 - `zz`, `zb`, `zt`; - `u` 和 `Ctrl+R` 撤销和重做; diff --git a/src/utils/veditutils.cpp b/src/utils/veditutils.cpp index 26410aa2..9373be2e 100644 --- a/src/utils/veditutils.cpp +++ b/src/utils/veditutils.cpp @@ -113,8 +113,6 @@ bool VEditUtils::indentBlockAsPreviousBlock(QTextCursor &p_cursor) changed = true; } - p_cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::MoveAnchor); - return changed; } diff --git a/src/utils/veditutils.h b/src/utils/veditutils.h index f963c217..691b6396 100644 --- a/src/utils/veditutils.h +++ b/src/utils/veditutils.h @@ -26,6 +26,7 @@ public: QTextCursor::MoveMode p_mode); // Indent current block as previous block. // Return true if some changes have been made. + // @p_cursor will be placed at the position after inserting leading spaces. static bool indentBlockAsPreviousBlock(QTextCursor &p_cursor); // Insert a new block at current position with the same indentation as