summaryrefslogtreecommitdiffstats
path: root/tests/mark/mark.qs
blob: 1c2521a49b6186a75496c7235dd8ba7e9c7119da (plain)
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
include("../test.js")

markMove()
markStays()
markMoveOnPrevChar()
markStaysOnNextChar()

function findYay(editor) {
    editor.gotoLine(1,0)
    editor.find("yay")
}

function markMove() {
    var editor = editors.openFile("test.cpp")
    findYay(editor)
    var mark = editor.createMark()
    editor.gotoLine(1,0)
    editor.insert("Hello World\n")
    findYay(editor)
    comparePositions(editor.position(),mark, "ensure mark moves on new lines")
    editor.close()
}

function markStays() {
    var editor = editors.openFile("test.cpp")
    findYay(editor)
    var mark = editor.createMark()
    editor.gotoLineEnd()
    editor.insert("Hello world")
    findYay(editor)
    comparePositions(editor.position(),mark, "ensure mark stays when inserting after the mark")
    editor.close()
}

function markMoveOnPrevChar() {
    var editor = editors.openFile("test.cpp")
    findYay(editor)
    var mark = editor.createMark()
    var pos = editor.position()
    editor.gotoPreviousCharacter(3)
    editor.insert("WOW")
    findYay(editor)
    comparePositions(editor.position(),mark, "ensure mark moves on insert at prev character")
    compare(mark.line,pos.line)
    compare(mark.column, pos.column+3)
    editor.close()
}

function markStaysOnNextChar() {
    var editor = editors.openFile("test.cpp")
    findYay(editor)
    var mark = editor.createMark()
    var pos = editor.position()
    editor.insert("WOW")
    findYay(editor)
    comparePositions(editor.position(),mark, "ensure mark stays the same when inserting after point")
    compare(mark.line,pos.line)
    compare(mark.column, pos.column)
    editor.close()

}