atom-python-black icon indicating copy to clipboard operation
atom-python-black copied to clipboard

Reformatting file deletes most of the file's content

Open laserson opened this issue 6 years ago • 12 comments

It requires a couple undo commands to recover the text. Using the latest 0.7.0 in Atom 1.32.2.

laserson avatar Dec 13 '18 17:12 laserson

Can you give me a bit more information about this? What version of atom and black. What settings you are using?

Thanks Mike

mikehoyio avatar Dec 14 '18 00:12 mikehoyio

Black is 18.9b0. I'm new to the Atom ecosystem, and I'm not sure how to give you any logs about what is happening.

laserson avatar Dec 17 '18 18:12 laserson

Yeah, it's doing the same for me too. It'll chop off the top half or bottom half of a file sometimes. Makes my code completely invalid.

haxys avatar Dec 17 '18 19:12 haxys

Atom: 1.33.0 x64 Mac OSX

Plugin: python-black 0.7.0

Black version: 18.9b0

haxys avatar Dec 17 '18 19:12 haxys

Reformatting seems to work perfectly in the command-line, but when I use Atom to do it, it mangles my code.

haxys avatar Dec 17 '18 19:12 haxys

I've had a go at recreating this and so far I cannot. Can you supply me with an example file that it breaks with? Also please let me know what settings you've got for the black plugin.

Cheers Mike

mikehoyio avatar Dec 18 '18 10:12 mikehoyio

The file that breaks is this one: https://github.com/AgoraMUD/AgoraMUD/blob/room-movement/libs/account.py

Here are my settings:

  • Path to black executable: Default: black
  • Format on save: True
  • Maximum line length: 79
  • Errors: Show until dismissed
  • Skip numeric underscore normalization: False
  • Skip string normalization: False
  • Keybindings: Enable (ctrl-alt-c to format)

haxys avatar Dec 18 '18 13:12 haxys

(Well, one of the files anyway.)

haxys avatar Dec 18 '18 13:12 haxys

I have the same problem. One of my python scripts has ~ 2000 lines, after I formatted with Black Pack (Alt + Ctrl + C), the script only has ~ 200 lines.

My setup:

  • SO: Ubuntu 18.04
  • Atom : 1.33.0
  • Electron: 2.0.11
  • Chrome : 61.0.3163.100
  • Node : 8.9.3
  • black: 18.9b0
  • python-black package: 0.7.0
    • python-black:
    • binPath: "black"
    • fmtOnSave: true
    • lineLength: 88
    • skipStringNormalization: false
    • skipNumericUnderscoreNormalization: false
    • showErrors: ["show", "hide", "flash"]

aoguedao avatar Jan 02 '19 20:01 aoguedao

I have the same issue with almost the same config

Atom: 1.33.0 x64 Mac OSX

Plugin: python-black 0.7.0

Black version: 18.9b0

arijitlaik avatar Jan 14 '19 09:01 arijitlaik

Just a bump to say this is still a problem. The file I was editing had ~300 lines, and goes down to <100 lines after running Black.

EDIT: Seeing how this project appears dead, my solution was to switch to atom-beautify. Since atom-beautify doesn't support configuring many Black options, I just edited the Black library locally to have the default configuration I wanted.

peterstory avatar Aug 07 '20 19:08 peterstory

Yup! Bump again - this just happened to me. Switching to something else

kmjc avatar Mar 30 '21 19:03 kmjc