@@ -6,60 +6,77 @@ function setupUI(protocol) {
66 ( function ( ) {
77 const vscode = acquireVsCodeApi ( ) ;
88 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 ) ;
1213
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 ] ;
1419
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+ } ) ;
1935
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+ } ) ;
2351
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" ;
2654
27- play_button . addEventListener ( "click" , ( ) => {
55+ playButton . addEventListener ( "click" , ( ) => {
2856 vscode . postMessage ( { type : UI_REQUESTS . RunToCheckpoint , value : container . dataset . checkpointId } ) ;
2957 } ) ;
3058
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" ;
3361
34- remove_button . addEventListener ( "click" , ( ) => {
62+ removeButton . addEventListener ( "click" , ( ) => {
3563 vscode . postMessage ( { type : UI_REQUESTS . DeleteCheckpoint , value : container . dataset . checkpointId } ) ;
3664 } ) ;
3765
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 ) ;
4971 }
50- const oldState = { checkpoints : [ ] } ;
51- /** @type {Array<CheckpointInfo> } */
52- let checkpoints = oldState . checkpoints ;
5372
54- updateCheckpointsList ( checkpoints ) ;
5573
5674 // Handle messages sent from the extension to the webview
5775 window . addEventListener ( "message" , ( event ) => {
5876 const message = event . data ; // The json data that the extension sent
5977 switch ( message . type ) {
6078 case UI_MESSAGES . ClearCheckpoints : {
61- checkpoints = [ ] ;
62- updateCheckpointsList ( checkpoints ) ;
79+ updateCheckpointsList ( [ ] ) ;
6380 break ;
6481 }
6582 case UI_MESSAGES . RemovedCheckpoint : {
@@ -83,20 +100,17 @@ function setupUI(protocol) {
83100 for ( const cp of checkpoints ) {
84101 const row = document . createElement ( "div" ) ;
85102 row . className = "checkpoints-list-row" ;
86- // row.role = "checkbox";
87- //row.ariaChecked = true;
88103 row . dataIndex = idx ;
89104 row . dataLastElement = idx == checkpoints . length - 1 ;
90105 row . dataset . index = idx ;
91106 row . dataset . checkpointId = cp . id ;
92107 row . ariaPosInSet = idx + 1 ;
108+ row . id = `cp-row-${ cp . id } ` ;
93109 create_row ( row , cp ) ;
94110 cp_list . appendChild ( row ) ;
95111
96112 idx += 1 ;
97113 }
98- // Update the saved state
99- vscode . setState ( { checkpoints : checkpoints } ) ;
100114 }
101115
102116 function removeCheckpoint ( checkpointId ) {
0 commit comments