Removes whitespaces and linebreaks

Hey guys,

been trying the most resent early acces version of PHPStorm and I run into this problem:

When I save a php. file in phpstorm it removes all whitespaces and linebreaks. This means the entire file becomes a single line which obviously gives a lot of problems.

It does not show this in php storm though, so I have to open it in another program to actually see what has happened. Opening the file initially it is showing way to many linebreaks which are not there in the file itself. Even if i leave them in, they get removed while saving the file.

Now i am not sure this is because of the version I am using, or something else but any clue as to why it would do this?

0
6 comments

Hi there,

Does it happen with local file or remote (after uploading)?

If local:

  • Where file is stored -- is it local SSD/HDD or network share/drive?
  • Please share such file (whole file, downloadable, not just copy-paste the text here)?

An in general:

  • IDE version?
  • OS?
  • File System used?
  • Program used to identify the issue?

BTW -- by "removes all whitespaces and linebreaks" you mean even leading spaces in each line? Even whitespace between parameters etc?

0
Avatar
Permanently deleted user

Hey Andriy,

It is stored local on my d disk.

IDE version = 2017.3 173.3727.138 van 28 november
OS = Windows 10
File system = I dont know..

Original file:

<?php

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "";


// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

?>

New file:
<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = ""; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } ?>

As seen in atom for example.

Not sure how to add the file but i think the content speaks for it self.

0

1) I understand the problem (what you get in the end) .. but I still want to see the actual file. Upload it to the Google Drive or alike and share the link.

2) If you close and reopen the project (or restart IDE) -- how does that file shows in PhpStorm?

3) Please post a screenshot of the whole IDE window with that file opened: I want to see how IDE displays it, what file icon it uses + some info from status bar. Ideally you use Default or Darcula theme, not custom ones like Material etc.

4) Does problem persist if you disable all custom (not bundled by default) plugins?

5) Do all of the plugins are up to date?

6) How did you install the IDE -- was it via built-in upgrade from previous version .. or was it a clean installation via installer into an empty folder?

7) Please also share your idea.log (Help | Show Log in XX)

0
Avatar
Permanently deleted user

ss of the file with the whitespaces that shouldnt be here..
https://imgur.com/a/RWHSD

link to the file:
https://www.dropbox.com/s/4up1j6b74m3c61p/dbconnect.php.tpl?dl=0

its weird because in dropbox it shows with the same empty lines i see in storm. Oh and i showed the tpl file instead of the .php file sinds it works the same.

it is a clean install which I just finised so no weird pluginns or templates active.

0

You have mixed line endings in your file -- you have CRLF (Windows) as well as just CR (which is old/classic Mac) -- that CR by itself is what most likely is causing the issue (Atom and some other editors may not be able to decode such mixed case or CR alone at all).

So .. change line endings for this file: either via status bar (where you see "CR") or "File | Line Separators". I suggest using Linux one (LF) -- it works fine for PHP/HTML/CSS/JS/etc on any OS.

I have no idea why you have mixed one there -- quite possibly you were trying to edit it after. IDE does not save mixed endings (based on my personal experience) -- it detected first line ending used and then applies it to ALL lines on save. So ... with ALL lines ending as CR it may indeed look like one solid line in other editors (not sure about Atom, but Windows' native Notepad will behave just like that).

 

1
Avatar
Permanently deleted user

That is so weird! But ye, seems you are right. Not really understand how this came to be or how to fix it, but gues thats not for this forum anyway..

ty for taking the time to help me out man!

0

Please sign in to leave a comment.