diff --git a/lib/clientstate-normalizer.js b/lib/clientstate-normalizer.js index 22f923776..bc2332cf8 100644 --- a/lib/clientstate-normalizer.js +++ b/lib/clientstate-normalizer.js @@ -78,6 +78,8 @@ export class ClientStateNormalizer { executor.argumentsVisible = component.componentState.argsPanelShown; executor.stdin = component.componentState.execStdin; executor.stdinVisible = component.componentState.stdinPanelShown; + if (component.componentState.wrap) + executor.wrap = true; session.executors.push(executor); } else if (component.componentName === 'ast') { @@ -286,6 +288,7 @@ class GoldenLayoutComponents { compilerOutShown: executor.compilerOutputVisible, argsPanelShown: executor.argumentsVisible, stdinPanelShown: executor.stdinVisible, + wrap: executor.wrap, }, isClosable: true, reorderEnabled: true, diff --git a/lib/clientstate.js b/lib/clientstate.js index 0d95103ae..8e1fbdb24 100644 --- a/lib/clientstate.js +++ b/lib/clientstate.js @@ -94,16 +94,18 @@ export class ClientStateCompiler { export class ClientStateExecutor { constructor(jsondata) { + this.compilerVisible = false; + this.compilerOutputVisible = false; + this.arguments = []; + this.argumentsVisible = false; + this.stdin = ''; + this.stdinVisible = false; + if (jsondata) { this.fromJsonData(jsondata); } else { this.compiler = new ClientStateCompiler(); - this.compilerVisible = false; - this.compilerOutputVisible = false; - this.arguments = []; - this.argumentsVisible = false; - this.stdin = ''; - this.stdinVisible = false; + this.wrap = false; } } @@ -120,6 +122,8 @@ export class ClientStateExecutor { this.stdin = jsondata.stdin; if (typeof jsondata.stdinVisible !== 'undefined') this.stdinVisible = jsondata.stdinVisible; + if (typeof jsondata.wrap !== 'undefined') + this.wrap = jsondata.wrap; this.compiler = new ClientStateCompiler(jsondata.compiler); } diff --git a/test/state/executor.json.normalized b/test/state/executor.json.normalized index 1d0e839c7..acf7ba3d5 100644 --- a/test/state/executor.json.normalized +++ b/test/state/executor.json.normalized @@ -53,7 +53,8 @@ "compilerOutputVisible": true, "compilerVisible": false, "stdin": "", - "stdinVisible": false + "stdinVisible": false, + "wrap": false } ] } diff --git a/test/state/executorwrap.json b/test/state/executorwrap.json new file mode 100644 index 000000000..4805bfe2a --- /dev/null +++ b/test/state/executorwrap.json @@ -0,0 +1,179 @@ +{ + "settings": { + "hasHeaders": true, + "constrainDragToContainer": false, + "reorderEnabled": true, + "selectionEnabled": false, + "popoutWholeStack": false, + "blockedPopoutsThrowError": true, + "closePopoutsOnUnload": true, + "showPopoutIcon": false, + "showMaximiseIcon": true, + "showCloseIcon": true, + "responsiveMode": "onload", + "tabOverlapAllowance": 0, + "reorderOnTabMenuClick": true, + "tabControlOffset": 10 + }, + "dimensions": { + "borderWidth": 5, + "borderGrabWidth": 15, + "minItemHeight": 10, + "minItemWidth": 10, + "headerHeight": 20, + "dragProxyWidth": 300, + "dragProxyHeight": 200 + }, + "labels": { + "close": "close", + "maximise": "maximise", + "minimise": "minimise", + "popout": "open in new window", + "popin": "pop in", + "tabDropdown": "additional tabs" + }, + "content": [ + { + "type": "column", + "isClosable": true, + "reorderEnabled": true, + "title": "", + "content": [ + { + "type": "stack", + "width": 100, + "height": 50, + "isClosable": true, + "reorderEnabled": true, + "title": "", + "activeItemIndex": 0, + "content": [ + { + "type": "component", + "componentName": "codeEditor", + "componentState": { + "id": 1, + "source": "// Type your code here, or load an example.\nint square(int num) {\n return num * num;\n}", + "lang": "c++", + "selection": { + "startLineNumber": 2, + "startColumn": 12, + "endLineNumber": 2, + "endColumn": 19, + "selectionStartLineNumber": 2, + "selectionStartColumn": 19, + "positionLineNumber": 2, + "positionColumn": 12 + }, + "fontScale": 14, + "fontUsePx": true + }, + "isClosable": true, + "reorderEnabled": true, + "title": "C++ source #1" + } + ] + }, + { + "type": "row", + "isClosable": true, + "reorderEnabled": true, + "title": "", + "height": 50, + "content": [ + { + "type": "stack", + "header": {}, + "isClosable": true, + "reorderEnabled": true, + "title": "", + "activeItemIndex": 0, + "height": 50, + "width": 50, + "content": [ + { + "type": "component", + "componentName": "compiler", + "componentState": { + "id": 1, + "compiler": "g111", + "source": 1, + "options": "", + "filters": { + "binary": false, + "execute": false, + "intel": true, + "demangle": true, + "labels": true, + "libraryCode": true, + "directives": true, + "commentOnly": true, + "trim": false + }, + "libs": [], + "lang": "c++", + "selection": { + "startLineNumber": 4, + "startColumn": 17, + "endLineNumber": 4, + "endColumn": 39, + "selectionStartLineNumber": 4, + "selectionStartColumn": 17, + "positionLineNumber": 4, + "positionColumn": 39 + }, + "fontScale": 14, + "fontUsePx": true + }, + "isClosable": true, + "reorderEnabled": true, + "title": "x86-64 gcc 11.1 (Editor #1, Compiler #1) C++" + } + ] + }, + { + "type": "stack", + "header": {}, + "isClosable": true, + "reorderEnabled": true, + "title": "", + "activeItemIndex": 0, + "width": 50, + "content": [ + { + "type": "component", + "componentName": "executor", + "componentState": { + "id": 1, + "compiler": "g111", + "source": 1, + "options": "", + "execArgs": "", + "execStdin": "", + "libs": [], + "lang": "c++", + "compilationPanelShown": true, + "compilerOutShown": true, + "argsPanelShown": false, + "stdinPanelShown": false, + "wrap": true, + "fontScale": 14, + "fontUsePx": true + }, + "isClosable": true, + "reorderEnabled": true, + "title": "x86-64 gcc 11.1 Executor (Editor #1) C++" + } + ] + } + ] + } + ] + } + ], + "isClosable": true, + "reorderEnabled": true, + "title": "", + "openPopouts": [], + "maximisedItemId": null +} \ No newline at end of file diff --git a/test/state/executorwrap.json.normalized b/test/state/executorwrap.json.normalized new file mode 100644 index 000000000..96fe2e498 --- /dev/null +++ b/test/state/executorwrap.json.normalized @@ -0,0 +1,57 @@ +{ + "sessions": [ + { + "id": 1, + "language": "c++", + "source": "// Type your code here, or load an example.\nint square(int num) {\n return num * num;\n}", + "conformanceview": false, + "compilers": [ + { + "id": "g111", + "options": "", + "filters": { + "binary": false, + "commentOnly": true, + "demangle": true, + "directives": true, + "execute": false, + "intel": true, + "labels": true, + "trim": false + }, + "libs": [], + "specialoutputs": [], + "tools": [] + } + ], + "executors": [ + { + "compilerVisible": true, + "compilerOutputVisible": true, + "arguments": "", + "argumentsVisible": false, + "stdin": "", + "stdinVisible": false, + "compiler": { + "id": "g111", + "options": "", + "filters": { + "binary": false, + "commentOnly": true, + "demangle": true, + "directives": true, + "execute": false, + "intel": true, + "labels": true, + "trim": false + }, + "libs": [], + "specialoutputs": [], + "tools": [] + }, + "wrap": true + } + ] + } + ] +} \ No newline at end of file diff --git a/test/statenormalisation-tests.js b/test/statenormalisation-tests.js index 16730005d..a7a4dfdbe 100644 --- a/test/statenormalisation-tests.js +++ b/test/statenormalisation-tests.js @@ -75,6 +75,18 @@ describe('Normalizing clientstate', () => { normalizer.normalized.should.deep.equal(resultdata); }); + + it('Should support newer features', () => { + const normalizer = new ClientStateNormalizer(); + + const data = JSON.parse(fs.readFileSync('test/state/executorwrap.json')); + + normalizer.fromGoldenLayout(data); + + const resultdata = JSON.parse(fs.readFileSync('test/state/executorwrap.json.normalized')); + + normalizer.normalized.should.deep.equal(resultdata); + }); }); describe('ClientState parsing', () => {