Skip to content

Commit

Permalink
Fix onivim#170 - Dead key / encoding issues (onivim#173)
Browse files Browse the repository at this point in the history
* Fix dead keys / UTF-8 character entry

* Formatting

* Remove logging

* Remove additional logging
  • Loading branch information
bryphe authored Mar 20, 2019
1 parent 53bacef commit 27e38a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion assets/viml/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ augroup END
function OniGetContext()
let bufferNumber = bufnr("%")
let line = line(".")
let column = col(".")
let column = virtcol(".")
let modified = getbufvar(bufferNumber, "&modified")

let context = [bufferNumber, line, column, modified]
Expand Down
10 changes: 5 additions & 5 deletions src/editor/Model/Tokenizer.re
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let _isNonWhitespace = c => !_isWhitespace(c);

let _moveToNextMatchingToken = (f, str, startIdx) => {
let idx = ref(startIdx);
let length = String.length(str);
let length = Zed_utf8.length(str);
let found = ref(false);

while (idx^ < length && ! found^) {
Expand All @@ -45,15 +45,15 @@ let _getAllTokens = (s: string, color: Color.t, startPos, endPos) => {
let idx = ref(startPos);
let tokens: ref(list(t)) = ref([]);

let endPos = min(endPos, String.length(s));
let endPos = min(endPos, Zed_utf8.length(s));

while (idx^ < endPos) {
let startToken = _moveToNextNonWhitespace(s, idx^);
let endToken = min(endPos, _moveToNextWhitespace(s, startToken + 1));

if (startToken < endPos) {
let length = endToken - startToken;
let text = String.sub(s, startToken, length);
let text = Zed_utf8.sub(s, startToken, length);

let token: t = {
text,
Expand Down Expand Up @@ -83,7 +83,7 @@ let rec getTokens =

let ret: list(t) =
switch (tokens) {
| [] => _getAllTokens(s, defaultForegroundColor, pos, String.length(s))
| [] => _getAllTokens(s, defaultForegroundColor, pos, Zed_utf8.length(s))
| [last] =>
_getAllTokens(
s,
Expand All @@ -94,7 +94,7 @@ let rec getTokens =
defaultBackgroundColor,
),
last.index,
String.length(s),
Zed_utf8.length(s),
)
| [v1, v2, ...tail] =>
let nextBatch =
Expand Down
7 changes: 5 additions & 2 deletions src/editor/bin/Input.re
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ open Oni_Model;
open Reglfw.Glfw;
open Reglfw.Glfw.Key;

open CamomileLibraryDefault.Camomile;

let keyPressToString = (~altKey, ~shiftKey, ~ctrlKey, ~superKey, s) => {
let s = s == "<" ? "lt" : s;

Expand All @@ -17,11 +19,12 @@ let keyPressToString = (~altKey, ~shiftKey, ~ctrlKey, ~superKey, s) => {
let s = altKey ? "A-" ++ s : s;
let s = superKey ? "D-" ++ s : s;

String.length(s) > 1 ? "<" ++ s ++ ">" : s;
let ret = Zed_utf8.length(s) > 1 ? "<" ++ s ++ ">" : s;
ret;
};

let charToCommand = (codepoint: int, mods: Modifier.t) => {
let char = String.make(1, Uchar.to_char(Uchar.of_int(codepoint)));
let char = Zed_utf8.singleton(UChar.of_int(codepoint));

let altKey = Modifier.isAltPressed(mods);
let ctrlKey = Modifier.isControlPressed(mods);
Expand Down

0 comments on commit 27e38a0

Please sign in to comment.