Skip to content

Commit

Permalink
#855 - Support Ukrainian layout; Fix matching of similar layouts (#856)
Browse files Browse the repository at this point in the history
*  #855 - Support Ukrainian layout; Fix matching of similar layouts

* Fix splitting of command line
  • Loading branch information
kozar authored and nvbn committed Nov 21, 2018
1 parent 1eaead4 commit dfd3187
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion thefuck/rules/switch_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
target_layout = '''qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?'''

source_layouts = [u'''йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,''',
u'''йцукенгшщзхїфівапролджєячсмитьбю.ЙЦУКЕНГШЩЗХЇФІВАПРОЛДЖЄЯЧСМИТЬБЮ,''',
u'''ضصثقفغعهخحجچشسیبلاتنمکگظطزرذدپو./ًٌٍَُِّْ][}{ؤئيإأآة»«:؛كٓژٰ‌ٔء><؟''',
u''';ςερτυθιοπ[]ασδφγηξκλ΄ζχψωβνμ,./:΅ΕΡΤΥΘΙΟΠ{}ΑΣΔΦΓΗΞΚΛ¨"ΖΧΨΩΒΝΜ<>?''',
u'''/'קראטוןםפ][שדגכעיחלךף,זסבהנמצתץ.QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?''']
Expand All @@ -15,7 +16,14 @@ def _get_matched_layout(command):
# result in a non-splitable sript as per shlex
cmd = command.script.split(' ')
for source_layout in source_layouts:
if all([ch in source_layout or ch in '-_' for ch in cmd[0]]):
is_all_match = True

for cmd_part in cmd:
if not all([ch in source_layout or ch in '-_' for ch in cmd_part]):
is_all_match = False
break

if is_all_match:
return source_layout


Expand Down

0 comments on commit dfd3187

Please sign in to comment.