Skip to content

Commit

Permalink
[fix]#44 非预期的输入还原问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hadix-lin committed Dec 22, 2019
1 parent cfcd14c commit 37bb295
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ gradle buildPlugin
也可以通过将`set keep-english-in-normal[-and-restore-in-insert]`加入到`~/.ideavimrc`文件中并重启IDE来启用插件功能。

## 更新历史
* 1.4.3
修正非预期的输入法回复问题 [#44](https://github.com/hadix-lin/ideavim_extension/issues/44)

* 1.4.2
1. 根据vim指令执行后编辑器状态来判断是否需要恢复输入法
2. 修正某些情况下恢复输入法出错的问题
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.util.*
import java.util.concurrent.TimeUnit

class LinFcitxRemoteSwitcher : InputMethodSwitcher {
private var lastStatus: Int = 0
private var lastStatus: Int = STATUS_UNKNOWN

override fun switchToEnglish() {
val current = getFcitxStatus()
Expand All @@ -21,6 +21,7 @@ class LinFcitxRemoteSwitcher : InputMethodSwitcher {
override fun restore() {
if (lastStatus == STATUS_ACTIVE) {
execFcitxRemote(FCITX_ACTIVE)
lastStatus = STATUS_UNKNOWN
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import io.github.hadixlin.iss.InputMethodSwitcher
import io.github.hadixlin.iss.mac.MacNative.getCurrentInputSourceID
import io.github.hadixlin.iss.mac.MacNative.switchInputSource
import org.apache.commons.lang.StringUtils
import org.apache.commons.lang.StringUtils.EMPTY

/**
* @author hadix
* @date 2018-12-23
*/
class MacInputMethodSwitcher : InputMethodSwitcher {

private var lastInputSource: String = StringUtils.EMPTY
@Volatile
private var lastInputSource: String = EMPTY

override fun switchToEnglish() {
val current = getCurrentInputSourceID()
Expand All @@ -27,11 +29,11 @@ class MacInputMethodSwitcher : InputMethodSwitcher {
}

override fun restore() {
val current = getCurrentInputSourceID()
if (lastInputSource == StringUtils.EMPTY || StringUtils.equals(lastInputSource, current)) {
if (lastInputSource == EMPTY) {
return
}
switchInputSource(lastInputSource)
lastInputSource = EMPTY
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class WinInputMethodSwitcher : InputMethodSwitcher {
}

override fun restore() {
val hwnd = WinNative.INSTANCE.GetForegroundWindow()
val current = getCurrentInputSource(hwnd)
if (lastInputSource < 0 || lastInputSource == current) {
if (lastInputSource < 0) {
return
}
val hwnd = WinNative.INSTANCE.GetForegroundWindow()
switchToInputSource(hwnd, lastInputSource)
lastInputSource = -1
}

companion object {
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>IdeaVimExtension</id>
<name>IdeaVimExtension</name>
<version>1.4.2</version>
<version>1.4.3</version>

<vendor
email="hadix.lin@gmail.com"
Expand Down Expand Up @@ -55,6 +55,8 @@
]]></description>

<change-notes><![CDATA[
<p>1.4.3<br/>
Fixed the unexpected input method restoration <a href=https://github.com/hadix-lin/ideavim_extension/issues/44>issue</a>
<p>1.4.2<br/>
1.Determine whether to restore the input method based on the state of the editor after the vim instruction is executed
2.Fix the problem of recovering input method in some cases
Expand All @@ -63,6 +65,8 @@
<p>1.4.0<br/>
support IdeaVim 0.54, keep consistent compatibility strategy with IdeaVim starting with this version.
<p>1.4.3<br/>
修正非预期的输入法回复<a href=https://github.com/hadix-lin/ideavim_extension/issues/44>问题</a>
<p>1.4.2<br/>
1.根据vim指令执行后编辑器状态来判断是否需要恢复输入法
2.修正某些情况下恢复输入法出错的问题
Expand Down

0 comments on commit 37bb295

Please sign in to comment.