Folding Extremely Long Lines In Code


#1

Is there a way to fold really long lines in .json file? It’s causing much lag. Here is an image:
(extremely long line of characters just for an image file idk why)


#2

Folding in Atom won’t prevent Atom from reading the line, and it’s the attempt that Atom is making to read the file that is causing problems.

The bottom line is that you can’t have a file like that open in Atom with how much busy work Atom does in the background to try to highlight everything. I think the best solution is to open database files in a lighter-weight editor like Notepad++.

Some months ago, I was working on a package to open files in Atom as true plain-text files (no highlighting or background work or anything), which would allow Atom to manage massive files like the one you have. Work on that has stalled because I had difficulty getting the cursor to work like I wanted it to, and then my actual work picked up and hasn’t slowed down much, but it’s still basically functional. You could git clone it and use apm link in the repo to create a symbolic link from .atom/packages/ to the code folder (this is a feature used for package development). It would allow you to open and read the file in Atom even if it doesn’t look very pretty.

(extremely long line of characters just for an image file idk why)

It’s probably an entire image file, given the name userDatabase.json. I would guess that that line is a user’s avatar.


#3

Hello.

Answering your question will not be of much help. To convince yourself that @DamnedScholar (I believe him) is giving you sound advice, I give some code to try in your keymap file.

### keymap.cson ###
'atom-text-editor':
    'ctrl-k ctrl-f': 'custom:fold-selected'

With this piece placed in your custom keymap file -

  • select the text

  • press ctrl-k,
    keep ctrl in; release k,
    press ctrl-f,
    release.

Then check the performance.

I recommend you have Atom V1.28.2 or later installed.

Regards.


#4

I uploaded the image using html and javascript and that’s the output, so userDatabase isn’t the image file. And yes, maybe ill use notepad++ for that.
error?


#5

No. It’s undesirable behavior, but it’s a symptom of how Atom is designed and the fact that we’re running a text editor in JavaScript. If Atom were coded in C++, it wouldn’t be a problem. If Atom didn’t try to touch and intimately understand every file in order to offer a rich user experience, the big lines wouldn’t be a problem. In the future, it may be that the devs are able to fine-tune Atom so that it’s not a problem (there is work currently underway to do just that). This problem is just a natural down side of everything else that’s going on.

I uploaded the image using html and javascript and that’s the output, so userDatabase isn’t the image file.

You used some JavaScript library that outputs a userDatabase.json file, and avatars tend to be pretty small, so it’s definitely possible for your server to have dropped the image into your .json file and end up with a massive, unintelligible line like that. Further reinforcing my belief is the fact that the file is named “database”. If the images aren’t being stored in the database, then where are they? What’s the key for that line?


#6

I didn’t use any library to create that file.


#7

So how did it appear?


#8

I have a website with an option to upload image and save it in the userDatabase.json file. Here is an image.


#9

And I’ve accidentally revealed my info ._.


#10

I do believe that’s what I said initially. That line in userDatabase.json is an image file. A small one, only a few thousand pixels, because it’s intended to be used as an avatar on the dating site you’re writing.

Your username isn’t compromising information.


#11

so, anyway, why does it have to be very large? it’s about 1M characters


#12

Databases aren’t meant to be edited directly, and when they are, it’s usually through a special program that can easily navigate such a large amount of data like phpMyAdmin. Atom definitely wasn’t made for that purpose.


#13

ok. gonna try out those kinds of programs for my database. I edit my database directly beause its still prototype.


#14

Also sometimes I upload 1366*768 which is the one im using for that.


#15

Did you write the whole thing? I don’t recommend writing your own database code. There are a lot of very mature, highly-optimized, open-source database libraries out there with large communities of experienced developers. If you intend to take your dating web site to a broader audience, you’re going to want to be able to handle massive traffic.