@@ -6,60 +6,77 @@ function setupUI(protocol) {
6
6
( function ( ) {
7
7
const vscode = acquireVsCodeApi ( ) ;
8
8
function create_row ( container , cp ) {
9
- let name = document . createElement ( "span" ) ;
10
- name . textContent = `${ cp . when } ` ;
11
- name . className = "checkpoints-list-when" ;
9
+ const checkpointEventNumber = document . createElement ( "span" ) ;
10
+ checkpointEventNumber . textContent = `${ cp . when } ` ;
11
+ checkpointEventNumber . className = "checkpoints-list-when" ;
12
+ container . appendChild ( checkpointEventNumber ) ;
12
13
13
- container . appendChild ( name ) ;
14
+ const checkpointName = document . createElement ( "span" ) ;
15
+ checkpointName . textContent = cp . name ;
16
+ checkpointName . className = "file-path" ;
17
+ checkpointName . addEventListener ( "click" , ( ) => {
18
+ const sourceLocPath = cp . where . path . split ( " at " ) [ 1 ] ;
14
19
15
- let path = document . createElement ( "span" ) ;
16
- path . textContent = cp . where . path ;
17
- path . className = "file-path" ;
18
- container . appendChild ( path ) ;
20
+ if ( sourceLocPath )
21
+ vscode . postMessage ( { type : UI_REQUESTS . GotoSourceLoc , value : { path : sourceLocPath , line : cp . where . line } } ) ;
22
+ } ) ;
23
+
24
+ checkpointName . addEventListener ( "keydown" , ( event ) => {
25
+ if ( event . keyCode === 13 ) {
26
+ checkpointName . contentEditable = false ;
27
+ event . target . blur ( ) ;
28
+ }
29
+ } ) ;
30
+
31
+ checkpointName . addEventListener ( "blur" , ( event ) => {
32
+ const payload = { checkpointId : cp . id , name : event . target . textContent } ;
33
+ vscode . postMessage ( { type : UI_MESSAGES . NameCheckpoint , value : payload } ) ;
34
+ } ) ;
19
35
20
- let action_bar = document . createElement ( "div" ) ;
21
- action_bar . className = "checkpoints-action-bar" ;
22
- let action_container = document . createElement ( "ul" ) ;
36
+ checkpointName . id = `cp-${ cp . id } ` ;
37
+
38
+ container . appendChild ( checkpointName ) ;
39
+
40
+ const actionBar = document . createElement ( "div" ) ;
41
+ actionBar . className = "checkpoints-action-bar" ;
42
+ let actionContainer = document . createElement ( "ul" ) ;
43
+
44
+ const editButton = document . createElement ( "li" ) ;
45
+ editButton . className = "row-button codicon codicon-edit" ;
46
+
47
+ editButton . addEventListener ( "click" , ( ) => {
48
+ checkpointName . contentEditable = true ;
49
+ checkpointName . focus ( ) ;
50
+ } ) ;
23
51
24
- let play_button = document . createElement ( "li" ) ;
25
- play_button . className = "row-button codicon codicon-debug-continue" ;
52
+ const playButton = document . createElement ( "li" ) ;
53
+ playButton . className = "row-button codicon codicon-debug-continue" ;
26
54
27
- play_button . addEventListener ( "click" , ( ) => {
55
+ playButton . addEventListener ( "click" , ( ) => {
28
56
vscode . postMessage ( { type : UI_REQUESTS . RunToCheckpoint , value : container . dataset . checkpointId } ) ;
29
57
} ) ;
30
58
31
- let remove_button = document . createElement ( "li" ) ;
32
- remove_button . className = "row-button codicon codicon-chrome-close" ;
59
+ const removeButton = document . createElement ( "li" ) ;
60
+ removeButton . className = "row-button codicon codicon-chrome-close" ;
33
61
34
- remove_button . addEventListener ( "click" , ( ) => {
62
+ removeButton . addEventListener ( "click" , ( ) => {
35
63
vscode . postMessage ( { type : UI_REQUESTS . DeleteCheckpoint , value : container . dataset . checkpointId } ) ;
36
64
} ) ;
37
65
38
- action_container . appendChild ( play_button ) ;
39
- action_container . appendChild ( remove_button ) ;
40
- action_bar . appendChild ( action_container ) ;
41
- container . appendChild ( action_bar ) ;
42
-
43
- let line = document . createElement ( "span" ) ;
44
- line . textContent = + cp . where . line ;
45
- line . className = "checkpoints-count-badge" ;
46
- container . appendChild ( line ) ;
47
- // div.appendChild(container);
48
- // return div;
66
+ actionContainer . appendChild ( editButton ) ;
67
+ actionContainer . appendChild ( playButton ) ;
68
+ actionContainer . appendChild ( removeButton ) ;
69
+ actionBar . appendChild ( actionContainer ) ;
70
+ container . appendChild ( actionBar ) ;
49
71
}
50
- const oldState = { checkpoints : [ ] } ;
51
- /** @type {Array<CheckpointInfo> } */
52
- let checkpoints = oldState . checkpoints ;
53
72
54
- updateCheckpointsList ( checkpoints ) ;
55
73
56
74
// Handle messages sent from the extension to the webview
57
75
window . addEventListener ( "message" , ( event ) => {
58
76
const message = event . data ; // The json data that the extension sent
59
77
switch ( message . type ) {
60
78
case UI_MESSAGES . ClearCheckpoints : {
61
- checkpoints = [ ] ;
62
- updateCheckpointsList ( checkpoints ) ;
79
+ updateCheckpointsList ( [ ] ) ;
63
80
break ;
64
81
}
65
82
case UI_MESSAGES . RemovedCheckpoint : {
@@ -83,20 +100,17 @@ function setupUI(protocol) {
83
100
for ( const cp of checkpoints ) {
84
101
const row = document . createElement ( "div" ) ;
85
102
row . className = "checkpoints-list-row" ;
86
- // row.role = "checkbox";
87
- //row.ariaChecked = true;
88
103
row . dataIndex = idx ;
89
104
row . dataLastElement = idx == checkpoints . length - 1 ;
90
105
row . dataset . index = idx ;
91
106
row . dataset . checkpointId = cp . id ;
92
107
row . ariaPosInSet = idx + 1 ;
108
+ row . id = `cp-row-${ cp . id } ` ;
93
109
create_row ( row , cp ) ;
94
110
cp_list . appendChild ( row ) ;
95
111
96
112
idx += 1 ;
97
113
}
98
- // Update the saved state
99
- vscode . setState ( { checkpoints : checkpoints } ) ;
100
114
}
101
115
102
116
function removeCheckpoint ( checkpointId ) {
0 commit comments