Skip to content
This repository was archived by the owner on May 27, 2020. It is now read-only.

Commit a85c11f

Browse files
authored
Dependency: libvim -> 8.10869.43 (#116)
* Dependency: libvim -> 8.10869.42 * Update clipboard API * Bump to [email protected] * Add clipboard cases for blockType character
1 parent f877a63 commit a85c11f

File tree

7 files changed

+88
-31
lines changed

7 files changed

+88
-31
lines changed

doc.esy.lock/index.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esy.lock/index.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@esy-ocaml/reason": "^3.4.0",
1919
"refmterr": "*",
2020
"ocaml": ">=4.7.0 <4.10.0",
21-
"libvim": "8.10869.41",
21+
"libvim": "8.10869.43",
2222
"editor-core-types": "onivim/editor-core-types#6a8afaf"
2323
},
2424
"resolutions": {

src/Types.re

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
type buffer;
22

3-
type clipboardProvider = int => option(array(string));
3+
type blockType =
4+
| Line
5+
| Character;
6+
7+
type clipboardContents = {
8+
lines: array(string),
9+
blockType,
10+
};
11+
12+
type clipboardProvider = int => option(clipboardContents);
413

514
type lineEnding =
615
| CR

src/bindings.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ void onWindowSplit(windowSplit_T splitType, char_u *path) {
240240
CAMLreturn0;
241241
}
242242

243-
int getClipboardCallback(int regname, int *num_lines, char_u ***lines) {
243+
int getClipboardCallback(int regname, int *num_lines, char_u ***lines,
244+
int *blockType) {
244245
CAMLparam0();
245-
CAMLlocal1(clipboardArray);
246+
CAMLlocal3(vRecord, clipboardArray, vBlockType);
246247

247248
static const value *lv_clipboardGet = NULL;
248249

@@ -255,7 +256,16 @@ int getClipboardCallback(int regname, int *num_lines, char_u ***lines) {
255256
int ret = 0;
256257
// Some
257258
if (Is_block(v)) {
258-
clipboardArray = Field(v, 0);
259+
vRecord = Field(v, 0);
260+
clipboardArray = Field(vRecord, 0);
261+
vBlockType = Int_val(Field(vRecord, 1));
262+
263+
if (vBlockType == 0) {
264+
*blockType = MLINE;
265+
} else {
266+
*blockType = MCHAR;
267+
}
268+
259269
int len = Wosize_val(clipboardArray);
260270

261271
*num_lines = len;

test.esy.lock/index.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/ClipboardTest.re

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ open EditorCoreTypes;
22
open Vim;
33
open TestFramework;
44

5+
open Types;
6+
57
let resetBuffer = () => Helpers.resetBuffer("test/testfile.txt");
68
let input = s => ignore(Vim.input(s));
79

8-
let makeFun = (s, _) => Some([|s|]);
10+
let makeFun = (s, _) => Some({lines: [|s|], blockType: Line});
911

1012
describe("Clipboard", ({describe, _}) => {
1113
describe("override", ({test, _}) => {
@@ -26,7 +28,7 @@ describe("Clipboard", ({describe, _}) => {
2628
test("return single line", ({expect, _}) => {
2729
let buf = resetBuffer();
2830

29-
Clipboard.setProvider(_ => Some([|"a"|]));
31+
Clipboard.setProvider(_ => Some({lines: [|"a"|], blockType: Line}));
3032

3133
input("y");
3234
input("y");
@@ -37,10 +39,46 @@ describe("Clipboard", ({describe, _}) => {
3739
expect.string(line).toEqual("a");
3840
});
3941

42+
test("return single line, blockType character", ({expect, _}) => {
43+
let buf = resetBuffer();
44+
45+
Clipboard.setProvider(_ =>
46+
Some({lines: [|"a"|], blockType: Character})
47+
);
48+
49+
input("y");
50+
input("y");
51+
input("p");
52+
53+
let line = Buffer.getLine(buf, Index.zero);
54+
55+
expect.string(line).toEqual("Tahis is the first line of a test file");
56+
});
57+
58+
test("return multiple lines, blockType character", ({expect, _}) => {
59+
let buf = resetBuffer();
60+
61+
Clipboard.setProvider(_ =>
62+
Some({lines: [|"a", "b"|], blockType: Character})
63+
);
64+
65+
input("y");
66+
input("y");
67+
input("p");
68+
69+
let line0 = Buffer.getLine(buf, Index.zero);
70+
let line1 = Buffer.getLine(buf, Index.(zero + 1));
71+
72+
expect.string(line0).toEqual("Ta");
73+
expect.string(line1).toEqual("bhis is the first line of a test file");
74+
});
75+
4076
test("return multiple lines", ({expect, _}) => {
4177
let buf = resetBuffer();
4278

43-
Clipboard.setProvider(_ => Some([|"a", "b", "c"|]));
79+
Clipboard.setProvider(_ =>
80+
Some({lines: [|"a", "b", "c"|], blockType: Line})
81+
);
4482

4583
input("y");
4684
input("y");

0 commit comments

Comments
 (0)