Skip to content

Commit cb2779d

Browse files
Revert this commit after branch create
1 parent 9b0edba commit cb2779d

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/dataEditor/dataEditorClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import * as child_process from 'child_process'
8585
import { osCheck } from '../utils'
8686
import { getCurrentConfig } from '../utils'
8787
import { isDFDLDebugSessionActive } from './include/utils'
88+
import { ViewoprtState } from './include/changes/changeMemento'
8889

8990
// *****************************************************************************
9091
// global constants
@@ -136,6 +137,7 @@ export function activate(ctx: vscode.ExtensionContext): void {
136137
// *****************************************************************************
137138

138139
export class DataEditorClient implements vscode.Disposable {
140+
private mementoState: ViewoprtState | undefined = undefined
139141
public panel: vscode.WebviewPanel
140142
private svelteWebviewInitializer: SvelteWebviewInitializer
141143
private displayState: DisplayState
@@ -296,6 +298,8 @@ export class DataEditorClient implements vscode.Disposable {
296298
return this.omegaSessionId
297299
}
298300

301+
private restoreState(state: ViewoprtState) {}
302+
299303
private async setupDataEditor() {
300304
assert(
301305
checkpointPath && checkpointPath.length > 0,
@@ -390,6 +394,7 @@ export class DataEditorClient implements vscode.Disposable {
390394
VIEWPORT_CAPACITY_MAX,
391395
false
392396
)
397+
393398
this.currentViewportId = viewportDataResponse.getViewportId()
394399
assert(this.currentViewportId.length > 0, 'currentViewportId is not set')
395400
await viewportSubscribe(this.panel, this.currentViewportId)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
export type ViewoprtState = {
2+
offset: number
3+
length: number
4+
bytesRemaining: number
5+
data: Uint8Array
6+
serial: number
7+
}
8+
export interface MementoOriginator {
9+
readonly id: string
10+
restore(state: ViewoprtState): void
11+
}
12+
export type MementoAttributes = {
13+
currentPos: number
14+
history: ViewoprtState[]
15+
}
16+
export interface MementoOperations {
17+
history(): MementoAttributes['history']
18+
undo(): void
19+
redo(): void
20+
save(): void
21+
}
22+
class SessionMemento{
23+
constructor(private state: ViewoprtState){}
24+
getState(){ return this.state }
25+
}
26+
27+
class MementoMgr {
28+
private mementoHistoryMap = new Map<string, MementoAttributes>()
29+
store(originator: MementoOriginator, attr: ViewoprtState){
30+
if(!this.mementoHistoryMap.get(originator.id))
31+
throw ""
32+
const attrs = this.mementoHistoryMap.get(originator.id)!
33+
attrs.history.push(attr)
34+
attrs.currentPos = attrs.history.length -1
35+
}
36+
undo(originator: MementoOriginator): void{
37+
if(!this.mementoHistoryMap.get(originator.id))
38+
throw ""
39+
const attrs = this.mementoHistoryMap.get(originator.id)!
40+
attrs.currentPos = attrs.history.length -1
41+
originator.restore()
42+
}
43+
44+
}
45+
46+
export function

0 commit comments

Comments
 (0)