octref / polacode

📸 Polaroid for your code
https://marketplace.visualstudio.com/items?itemName=pnp.polacode
6.82k stars 184 forks source link

Weird formatting after taking shot #109

Open ghost opened 5 years ago

ghost commented 5 years ago

Everything looks fine in vscode. DeepinScreenshot_20190510112617

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

octref commented 5 years ago

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

ghost commented 5 years ago

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);
octref commented 5 years ago

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:

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).

mirkancal commented 5 years ago

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

image

liyiming22 commented 5 years ago

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

img

micalevisk commented 5 years ago

Same here.

vscode help

font spec

Language: javascript

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

print

edevars commented 5 years ago

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

detj commented 5 years ago

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?

ossie-git commented 5 years ago

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');
the-dr-lazy commented 5 years ago

Also, I encountered the same issue.

mor10 commented 5 years ago

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.

talentlessguy commented 5 years ago

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

GeroCoded commented 5 years ago

Same here.

image

Polacode Preview Polacode_error1

Polacode Result Polacode_error2

the-dr-lazy commented 5 years ago

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

octref commented 5 years ago

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.

mmirus commented 5 years ago

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)

deftomat commented 5 years ago

v0.3.4 and still the same issue

chiangs commented 5 years ago

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

mmirus commented 5 years ago

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.

kufii commented 5 years ago

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

kufii commented 5 years ago

@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.

nas5w commented 4 years ago

Also experiencing this issue!

Versions: VS Code 1.40.2 Polacode 0.3.4 Ubuntu 18.10

diy-router

kufii commented 4 years ago

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

RafaelRey commented 4 years ago

same issue here, Ubuntu 18.04 and VsCode 1.45.0 issue code

LuigiR0jas commented 4 years ago

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

SaizFerri commented 3 years ago

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

FrancescoSaverioZuppichini commented 3 years ago

same

fgarcia5 commented 3 years ago

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

This worked for me. Thanks for sharing!

astrolemonade commented 1 year ago

Is there a way to avoid resetting the zoom level?

FrancescoSaverioZuppichini commented 1 year ago

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

salif commented 7 months ago

For me, it works with zooming in, but not with reseting the zoom