-
Notifications
You must be signed in to change notification settings - Fork 274
/
Regression1671Test.re
70 lines (62 loc) · 2.06 KB
/
Regression1671Test.re
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
open Oni_Core;
open Oni_Model;
open Oni_IntegrationTestLib;
// Validate that unsaved changes persist when switching buffers
// Regression test for: https://github.com/onivim/oni2/issues/1671
runTestWithInput(
~name="Regression1671 - Opening new buffer loses changes in previous buffer",
(input, _dispatch, wait, _runEffects) => {
wait(~name="Capture initial state", (state: State.t) =>
Feature_Vim.mode(state.vim) == Vim.Mode.Normal
);
input(":e a-test-file");
input("<CR>");
input("iabc");
//ignore(Vim.command("e a-test-file"): Vim.Context.t);
// Wait for lines to be available in buffer
let originalBufferId = ref(-1);
wait(~name="Buffer gets updated", (state: State.t) =>
state
|> Selectors.getActiveBuffer
|> Option.map(buffer => {
let lines = Buffer.getLines(buffer);
originalBufferId := Buffer.getId(buffer);
prerr_endline(lines[0]);
lines[0] == "abc";
})
|> Option.value(~default=false)
);
input("<ESC>");
// Repro for 1671 - switch to a different file, and then back
input(":e! another-test-file");
input("<CR>");
wait(~name="Buffer switched", (state: State.t) => {
state
|> Selectors.getActiveBuffer
|> Option.map(buffer => {Buffer.getId(buffer) != originalBufferId^})
|> Option.value(~default=false)
});
input("<ESC>");
input(":e! a-test-file");
input("<CR>");
wait(~name="Buffer switched back", (state: State.t) => {
state
|> Selectors.getActiveBuffer
|> Option.map(buffer => {Buffer.getId(buffer) == originalBufferId^})
|> Option.value(~default=false)
});
// Buffer modifications should still be around!
wait(
~name="Buffer updates are still around after switching back",
(state: State.t) =>
state
|> Selectors.getActiveBuffer
|> Option.map(buffer => {
let lines = Buffer.getLines(buffer);
prerr_endline(lines[0]);
lines[0] == "abc";
})
|> Option.value(~default=false)
);
},
);