polacode icon indicating copy to clipboard operation
polacode copied to clipboard

Weird formatting after taking shot

Open ghost opened this issue 5 years ago • 31 comments

Everything looks fine in vscode. DeepinScreenshot_20190510112617

After taking the screenshot. The code lines break in a very weird way code

ghost avatar May 10 '19 08:05 ghost

Can you paste the original source code here, along with the font you are using (I guess it's Operator Mono?)

octref avatar May 10 '19 16:05 octref

The font is Operator Mono. I read other issues and changed the font to Fira Code but it didn't make any difference.

This is the code I was trying to make a screenshot

storeSchema.pre('save', function(next) {
  if (!this.isModified('name')) {
    next(); // skip it
    return; // stop function from running
  }
  this.slug = slug(this.name);
  next();
  // TODO: @mwamodojnr make more resiliant so slugs are unique
});

This is the whole file

const mongoose = require('mongoose');
const slug = require('slugs');

mongoose.Promise = global.Promise;

const storeSchema = new mongoose.Schema({
  name: {
    type: String,
    trim: true,
    required: 'Please enter a store name!',
  },
  slug: String,
  description: {
    type: String,
    trim: true,
  },
  tags: [String],
});

storeSchema.pre('save', function(next) {
  if (!this.isModified('name')) {
    next(); // skip it
    return; // stop function from running
  }
  this.slug = slug(this.name);
  next();
  // TODO: @mwamodojnr make more resiliant so slugs are unique
});

module.exports = mongoose.model('Store', storeSchema);

ghost avatar May 10 '19 21:05 ghost

I cannot reproduce it on either macOS or Windows.

Does it happen for this snippet?

const storeSchema = new mongoose.Schema({
  name: {
    type: String,
    trim: true,
    required: 'Please enter a store name!',
  },
  slug: String,
  description: {
    type: String,
    trim: true,
  },
  tags: [String],
});

Also if you do have some time, you can try tweaking the CSS styles:

  • Clone this repo
  • Open it in VS Code
  • Run the Launch Polacode debug target
  • In the new window, you can run command "Developer: Open Webview Developer Tools" to inspect the Polacode tab once it's open

Would be great if you can try running it by commenting out these lines:

https://github.com/octref/polacode/blob/d8224771b1557faade68b39c55710a2383c34280/webview/index.js#L144-L148

So you should get exactly what you get in the editor (now it's 2x).

octref avatar May 10 '19 21:05 octref

I'm on vscode 1.33.1 on fedora 30. I'm facing same issue with flutter/dart code.

image

mirkancal avatar May 12 '19 13:05 mirkancal

Same here. System: Manjaro Linux 18.0.4 VS Code: 1.35.0 Language: JavaScript

img

liyiming22 avatar Jun 12 '19 09:06 liyiming22

Same here.

vscode help

font spec

Language: javascript

if (true) {
  console.log(foobar); // idk
  const foo = [1, 2,3 ];
}

print

micalevisk avatar Jun 15 '19 00:06 micalevisk

I had the same issue in fedora 30, the font is operator mono. I tried with other fonts like Fira Code, but doesn't works. I also disabled the font ligatures but the result is the same

Polacode in vscode

Screenshot from 2019-06-25 14-13-40

The image after saving

code

edevars avatar Jun 25 '19 19:06 edevars

Facing this line wrapping issue in v0.3.2. Is it because while capturing the shot, it uses different CSS where the word wrapping settings are different from the CSS being used in screen render in VSCode?

detj avatar Jun 30 '19 12:06 detj

I ran into the same issue. Here is what a screenshot of it looks like:

screenshot

while the image generated by polacode looks like this:

code

and the corresponding code snippet:

//npm modules
const express = require('express');
const uuid = require('uuid/v4')
const session = require('express-session')
const FileStore = require('session-file-store')(session);
const bodyParser = require('body-parser');
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const axios = require('axios');
const bcrypt = require('bcrypt');

ossie-git avatar Jul 03 '19 23:07 ossie-git

Also, I encountered the same issue.

the-dr-lazy avatar Jul 19 '19 17:07 the-dr-lazy

Same issue. Standard install. MacOS, latest VS Code release, fresh install of Polacode, no configurations:

Preview in VS Code: Screen Shot 2019-07-22 at 1 35 58 PM

Saved file: prettier

This happens across .css, .js, .php, and .json files.

mor10 avatar Jul 22 '19 20:07 mor10

Same. Ubuntu 18.04, VS Code 1.36.1 Screenshot from 2019-08-05 13-31-45

talentlessguy avatar Aug 06 '19 15:08 talentlessguy

Same here.

image

Polacode Preview Polacode_error1

Polacode Result Polacode_error2

GeroCoded avatar Sep 02 '19 20:09 GeroCoded

The issue has been resolved for me! IDK how! I'm on OS X 10.14.6 and VS Code 1.37.1.

the-dr-lazy avatar Sep 03 '19 06:09 the-dr-lazy

Think #121 by @kufii would fix this. I published the changes in 0.3.3. Please let me know if it fixes it for you.

octref avatar Sep 24 '19 17:09 octref

Still having this problem, unfortunately.

Name: Polacode Id: pnp.polacode Description: 📸 Polaroid for your code Version: 0.3.3 Publisher: P & P VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=pnp.polacode

Version: 1.38.1 (user setup) Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0 Date: 2019-09-11T13:35:15.005Z Electron: 4.2.10 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Windows_NT x64 10.0.17134

(Developing on WSL if it matters)

mmirus avatar Sep 24 '19 18:09 mmirus

v0.3.4 and still the same issue

deftomat avatar Oct 02 '19 10:10 deftomat

I have VS code on a window zoom of -1, the formatting is fine before taking the snap, then the output is all wrong as others have shown. As soon as I put the zoom back at 0, the output is consistently fine.

Using MacOS X, VS Code, Night owl theme, Dank Mono

chiangs avatar Oct 02 '19 13:10 chiangs

Oh shoot, same here. Resetting the zoom level from -1 (what I normally prefer) to 0 fixes the problem. Reducing the editor font size in the settings without using the zoom feature seems to work okay too.

mmirus avatar Oct 02 '19 14:10 mmirus

I haven't been able to figure out why, but resetting zoom, and enabling ligatures fixes the issue

kufii avatar Oct 03 '19 20:10 kufii

@octref after playing around with dom-to-image I've discovered this issue can be fixed by setting white-space: nowrap on the code spans.

kufii avatar Oct 04 '19 14:10 kufii

Also experiencing this issue!

Versions: VS Code 1.40.2 Polacode 0.3.4 Ubuntu 18.10

diy-router

nas5w avatar Nov 27 '19 02:11 nas5w

I made a project inspired by polacode with fixes for issues like this. if you'd like you can use it while we wait for it to be fixed in polacode? https://marketplace.visualstudio.com/items?itemName=adpyke.codesnap

kufii avatar Nov 27 '19 14:11 kufii

same issue here, Ubuntu 18.04 and VsCode 1.45.0 issue code

RafaelRey avatar May 11 '20 19:05 RafaelRey

Same, Ubuntu 20.04 LTS

VS Code version: 1.47.3 Commit: 91899dcef7b8110878ea59626991a18c8a6a1b3e Date: 2020-07-23T15:51:39.791Z Electron: 7.3.2 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Linux x64 5.4.0-42-generic

Screenshot from 2020-08-13 16-57-18 code

LuigiR0jas avatar Aug 13 '20 22:08 LuigiR0jas

I had the same issue, reseting the zoom of VSCode to 0 solves the problem 👌

SaizFerri avatar Jan 23 '21 21:01 SaizFerri

same

I had the same issue, reseting the zoom of VSCode to 0 solves the problem 👌

This worked for me. Thanks for sharing!

fgarcia5 avatar Oct 11 '21 20:10 fgarcia5

Is there a way to avoid resetting the zoom level?

astrolemonade avatar Nov 12 '22 21:11 astrolemonade

use carbon insted https://carbon.now.sh/