hyperlayout icon indicating copy to clipboard operation
hyperlayout copied to clipboard

Hyperlayout does nothing: SyntaxError

Open Donaldini opened this issue 7 years ago • 4 comments

I'm getting errors in my console when I try out an example.

2018-02-01 13_51_16-developer tools - file____c__users_donaldv_appdata_local_hyper_app-1 4 8_resourc

The black rectangle is Hyper, but it doesn't like to be screenshotted for some reason :) All I did was run: hyperlayout

Donaldini avatar Feb 01 '18 13:02 Donaldini

Hi, I am getting the same on a Windows 8.1 machine: Hyper version: 1.4.8 hyperlayout: 0.2.1 node: 8.9.4

Apparently the problem is that the string to be parsed as JSON to the middlewares is not valid, this is the output of the string: "{"config":{"entry":"tab","layout":[["echo 'hola'","echo 'adios'"]]},"cwd":"C:\Users\Alvaro_2"}[0K[?25l" so after the correct json object is adding extra stuff. But that object has more elements that also have more extra characters:

image

I did the same as Donaldini, just create the .hyperlayout file and run hyperlayout on hyper

AlvaroL avatar Feb 03 '18 15:02 AlvaroL

The issue can be fixed by editing index.js:162 From const config = JSON.parse(testedData[1]) to const config = JSON.parse(testedData[1].substring(0, testedData[1].lastIndexOf('}') + 1));

peternycander avatar May 07 '18 16:05 peternycander

The issue can be fixed by editing index.js:162 From const config = JSON.parse(testedData[1]) to const config = JSON.parse(testedData[1].substring(0, testedData[1].lastIndexOf('}') + 1));

Tried this, ended up crashing my terminal. Not entirely sure why.

NeonWizard avatar Nov 14 '18 16:11 NeonWizard

Hello guys,

I have tried to use this code to fix this error, but I had some problems. I think this code is best when you use multiple layouts:

let dataJson = testedData['input']
            .replace('<0x1b>[0Kl<0x1b>[?25l', '')
            .replace('<0x1b>[0Kn', '')
            .replace(/(\r\n|\n|\r)/gm, '')
            .split('[hyperlayout config]:')[1]
            .split('<0x1b>[0K')[0]
            .replace('<0x1b>[0Kl<0x1b>[?25l', '');

const config = JSON.parse(dataJson);

<0x1b> is a symbol that appear in console. I just copy and paste to replace in code. You may have to add more symbols in .replace because different symbols appear depending on my configuration.

assisgui avatar Apr 24 '19 13:04 assisgui