Browse Source

bug-fix: some minor bug fixes

1. Refine VUpdater to compare versions with different sections, such as
1.2.3 or 1.2;
2. Update shortcuts help;
3. Fix bug with autoindent and autolist.
Le Tan 8 years ago
parent
commit
003ba7a1f2

+ 17 - 10
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;
     }
 }
 

+ 3 - 3
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 `<leader>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;

+ 3 - 3
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`)
     - 目前 `<leader>y/d/p` 等同于 `"+y/d/p`, 从而可以访问系统剪切板。
 - `zz`, `zb`, `zt`;
 - `u` 和 `Ctrl+R` 撤销和重做;

+ 0 - 2
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;
 }
 

+ 1 - 0
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