Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux ubuntu 通过 subl 命令打开 sublime-text 输入法退格问题 #46

Open
steven-ok opened this issue Sep 13, 2017 · 7 comments

Comments

@steven-ok
Copy link

在Linux 上通过命令打开 sublime-text ,输入法在输入中文出现候选字的时候(这个时候还未选择汉字),现在按下退格,将不能删除输入框上的 字母拼音, 而是删除了编辑文件的内容,候选框依然无法消失,依然还显示在屏幕上,然而用图标打开 sublime text 就不会出现这个问题

@nemo-nullius
Copy link

nemo-nullius commented Sep 22, 2017

Actually, even if I open sublime-text by clicking on the icon, I still have this problem of deleting words in the wrong place...

So could you kindly show me the configuration in your sublime-text.desktop please? @Xiang-DangDang

@steven-ok
Copy link
Author

我的配置文件没有改动过,下载安装后,除了安装你提供的 sublime-text-imfix 插件,没有过任何改动,我使用的操作系统为 基于 debian 的 deepin,以下是我的 sublime-text 配置文件,目前使用最新版本的sublime-text,这个问题在以前版本也出现

[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
#Exec=/opt/sublime_text/sublime_text %F
Exec=/usr/bin/subl %F
Terminal=false
MimeType=text/plain;
Icon=sublime-text
Categories=TextEditor;Development;
StartupNotify=true
Actions=Window;Document;
StartupWMClass=Sublime_text

[Desktop Action Window]
Name=New Window
#Exec=/opt/sublime_text/sublime_text -n
Exec=/usr/bin/subl -n
OnlyShowIn=Unity;

[Desktop Action Document]
Name=New File
#Exec=/opt/sublime_text/sublime_text --command new_file
Exec=/usr/bin/subl --command new_file
OnlyShowIn=Unity;

@nemo-nullius
Copy link

nemo-nullius commented Sep 22, 2017

你好!

首先我不是作者,我也是同样遇到这个问题的使用者。

不过我的状况更糟一些,因为我即便双击图标打开 sublime 也无法正常使用退格键。另外,在我的系统里,直接使用作者提供的 .so 文件是无法在 sublime 里成功使用 fcitx 的——每次切换到 fcitx ,都会立即跳回为英文输入法,完全无法使用。还得先修改源代码,将其中关于 fcitx 的部分删掉,只保留关于 xim 的部分,再重新编译为 .so 文件,这时才能在 sublime 里用 fcitx 。(我自己开了个 issue 描述这个奇怪的问题,不过作者回复说无法重现,见 #50 )不过这样带来的好处是, ibus 倒能用了。。。

我的系统是:

  • Ubuntu 14.04 + i3wm (其实在 xfce4/mate 桌面下也试过,都不行)
  • fcitx 4.2.8.5
  • Sublime Text 3 Build 3143

这样看来,还是只能滚回继续用 vim 了。。但好喜欢 sublime 的新配色 Mariana 啊 T_T 。。

@nemo-nullius
Copy link

nemo-nullius commented Sep 22, 2017

Now I have come up with a way to partially solve this problem of deleting with backspace. Although it has some shortcomings, it could at least provide a fairly acceptive experience of typing Chinese characters with fcitx.

  1. Open Preferences -> Key Bindings in sublime.
  2. Copy all the contents from the left column (Default) to the right column (User).
  3. Comment this line : //{ "keys": ["backspace"], "command": "left_delete" }, in the right column (User). (It is Line 19 in my file.)
  4. Open a terminal, and go into the configuration folder of sublime, like ~/.config/sublime-text-3/Packages/.
  5. Make a new folder "Default" in the folder "Packages": mkdir Default.
  6. Copy the user keymap file to this "Default" folder: cp ./User/Default\ \(Linux\).sublime-keymap ./Default

Now backspace will behave correctly - it will delete words in the input box of fcitx rather than in sublime.

The theory is that although the default .sublime-keymap is read-only, the .sublime-keymap file in the Default folder will override the original default one, and thus we can modify it. Therefore, with the line of backspace key in the default keymap file deleted, sublime loses the control of backspace, and thus fcitx could get control of that key when in need.

But this method is not perfect. It has a side effect - the backspace key can never be used in sublime any more. To work around, we can just use shift+backspace which has the same function with backspace, or try to use del key, or even vim mode. : )

Reference:
https://forum.sublimetext.com/t/input-method-support/5446/30 (See stevenfrog's post)

PS.
If you are using some plugins concerning applying (new) keymap, also remember to comment/delete the lines with backspace key involved, or the plugins will ask sublime to back again take control of backspace and never give the control of that key to fcitx. Like as for the package ActuralVim, we need to comment // { "keys": ["backspace"], "args": {"key": "<bs>"}, "context": [{ "key": "setting.actual_intercept", "operand": true }], "command": "actual_keypress" }, (Line 23 in my file) in the keymap configuration file of ActualVim, which is ~/.config/sublime-text-3/Packages/ActualVim/Default.sublime-keymap.

PSS.
In order not to cause some other bugs in ActualVim, like the wrong behavior of insert after deleting with shift+backspace - the words are inserted in the position before deleting rather than after it, we should change "backspace" to "shift+backspace" in the line mentioned above in the keymap configuration file of ActualVim, rather than simply comment/delete that line.

@videni
Copy link

videni commented Nov 17, 2017

我也同样遇到了这个问题。不过,我不是通过subl命令打开,而是,直接点击sublime桌面图标打开。

@ppflower
Copy link

ppflower commented Feb 6, 2018

在我这里只有新创建的文件被保存的时候才会发生这种问题。cmd/ctrl+s保存完接着编辑的时候所有的窗口都会出现delete键删除不正常的问题。

@zh-zheng
Copy link

在我这里只有新创建的文件被保存的时候才会发生这种问题。cmd/ctrl+s保存完接着编辑的时候所有的窗口都会出现delete键删除不正常的问题。

我也是这样,现在我明白什么时候才会触发了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants