+2
-2
data/core/commands/doc.lua
+2
-2
data/core/commands/doc.lua
···
320
320
local translations = {
321
321
["previous-char"] = translate.previous_char,
322
322
["next-char"] = translate.next_char,
323
-
["previous-word-boundary"] = translate.previous_word_boundary,
324
-
["next-word-boundary"] = translate.next_word_boundary,
323
+
["previous-word-start"] = translate.previous_word_start,
324
+
["next-word-end"] = translate.next_word_end,
325
325
["previous-start-of-block"] = translate.previous_start_of_block,
326
326
["next-start-of-block"] = translate.next_start_of_block,
327
327
["start-of-doc"] = translate.start_of_doc,
+19
-20
data/core/doc/translate.lua
+19
-20
data/core/doc/translate.lua
···
28
28
end
29
29
30
30
31
-
function translate.previous_word_boundary(doc, line, col)
32
-
local char = doc:get_char(doc:position_offset(line, col, -1))
33
-
local inword = not is_non_word(char)
34
-
repeat
35
-
local line2, col2 = line, col
36
-
line, col = doc:position_offset(line, col, -1)
37
-
if line == line2 and col == col2 then
31
+
function translate.previous_word_start(doc, line, col)
32
+
local prev
33
+
while line > 1 or col > 1 do
34
+
local l, c = doc:position_offset(line, col, -1)
35
+
local char = doc:get_char(l, c)
36
+
if prev and prev ~= char or not is_non_word(char) then
38
37
break
39
38
end
40
-
local c = doc:get_char(doc:position_offset(line, col, -1))
41
-
until inword and is_non_word(c) or not inword and c ~= char
42
-
return line, col
39
+
prev, line, col = char, l, c
40
+
end
41
+
return translate.start_of_word(doc, line, col)
43
42
end
44
43
45
44
46
-
function translate.next_word_boundary(doc, line, col)
47
-
local char = doc:get_char(line, col)
48
-
local inword = not is_non_word(char)
49
-
repeat
50
-
local line2, col2 = line, col
51
-
line, col = doc:position_offset(line, col, 1)
52
-
if line == line2 and col == col2 then
45
+
function translate.next_word_end(doc, line, col)
46
+
local prev
47
+
local end_line, end_col = translate.end_of_doc(doc, line, col)
48
+
while line < end_line or col < end_col do
49
+
local char = doc:get_char(line, col)
50
+
if prev and prev ~= char or not is_non_word(char) then
53
51
break
54
52
end
55
-
local c = doc:get_char(line, col)
56
-
until inword and is_non_word(c) or not inword and c ~= char
57
-
return line, col
53
+
line, col = doc:position_offset(line, col, 1)
54
+
prev = char
55
+
end
56
+
return translate.end_of_word(doc, line, col)
58
57
end
59
58
60
59
+8
-8
data/core/keymap.lua
+8
-8
data/core/keymap.lua
···
132
132
["shift+tab"] = "doc:unindent",
133
133
["backspace"] = "doc:backspace",
134
134
["shift+backspace"] = "doc:backspace",
135
-
["ctrl+backspace"] = "doc:delete-to-previous-word-boundary",
136
-
["ctrl+shift+backspace"] = "doc:delete-to-previous-word-boundary",
135
+
["ctrl+backspace"] = "doc:delete-to-previous-word-start",
136
+
["ctrl+shift+backspace"] = "doc:delete-to-previous-word-start",
137
137
["delete"] = "doc:delete",
138
138
["shift+delete"] = "doc:delete",
139
-
["ctrl+delete"] = "doc:delete-to-next-word-boundary",
140
-
["ctrl+shift+delete"] = "doc:delete-to-next-word-boundary",
139
+
["ctrl+delete"] = "doc:delete-to-next-word-end",
140
+
["ctrl+shift+delete"] = "doc:delete-to-next-word-end",
141
141
["return"] = { "command:submit", "doc:newline" },
142
142
["ctrl+return"] = "doc:newline-below",
143
143
["ctrl+shift+return"] = "doc:newline-above",
···
155
155
["right"] = "doc:move-to-next-char",
156
156
["up"] = { "command:select-previous", "doc:move-to-previous-line" },
157
157
["down"] = { "command:select-next", "doc:move-to-next-line" },
158
-
["ctrl+left"] = "doc:move-to-previous-word-boundary",
159
-
["ctrl+right"] = "doc:move-to-next-word-boundary",
158
+
["ctrl+left"] = "doc:move-to-previous-word-start",
159
+
["ctrl+right"] = "doc:move-to-next-word-end",
160
160
["ctrl+["] = "doc:move-to-previous-start-of-block",
161
161
["ctrl+]"] = "doc:move-to-next-start-of-block",
162
162
["home"] = "doc:move-to-start-of-line",
···
170
170
["shift+right"] = "doc:select-to-next-char",
171
171
["shift+up"] = "doc:select-to-previous-line",
172
172
["shift+down"] = "doc:select-to-next-line",
173
-
["ctrl+shift+left"] = "doc:select-to-previous-word-boundary",
174
-
["ctrl+shift+right"] = "doc:select-to-next-word-boundary",
173
+
["ctrl+shift+left"] = "doc:select-to-previous-word-start",
174
+
["ctrl+shift+right"] = "doc:select-to-next-word-end",
175
175
["ctrl+shift+["] = "doc:select-to-previous-start-of-block",
176
176
["ctrl+shift+]"] = "doc:select-to-next-start-of-block",
177
177
["shift+home"] = "doc:select-to-start-of-line",