Sublime Forum

Reindent problem

#1

Hi

I use last build 4126 and Reindent operation start working not propertly:

Is there way to fix wrong working of reindend?

Thanks
$result = q(“SELECT
n.expenseID,
COUNT(n.id) AS num
FROM
sError_notify AS n
WHERE
n.expenseID IN (”.implode(",", array_keys($IDs)).")
AND n.isActive=1
GROUP BY n.expenseID");
while ($r = $result->fetch_assoc()) {
$json[‘results’][‘expenseList’][‘result’][$r[‘expenseID’]][‘errorNum’]=$r[‘num’];
}

0 Likes

#2

I don’t think a code formatter will modify your string, which is technically a misbehavior.

0 Likes

#3

I write wrong! This is Reindent operation! Not pretty code

Just when i add “…” to insert variable - it make wrong pretty string.
What you mean: which is technically a misbehavior.

0 Likes

#4

this seems to be caused by the .") part at the end of the line specifically. If you take the bracket out the string (i.e. remove the "), it indents correctly.

After some experimentation, I have identified its the

<key>indentParens</key>
<true/>

from Packages/Default/Indentation Rules.tmPreferences which is causing this.

1 Like

#5

Cant find this file in packages. Search by file name cant file also this files.
As i understand, you recommend change setting in this file yes?

0 Likes

#6

What version of sublime text you use? I cant find this file(

0 Likes

#7

The given virtual filesystem path Packages/Default/... points to ST’s Default.sublime-package (see: C:\Program Files\Sublime Text\Packages\Default.sublime-package).

If this setting is really the root cause you could create a syntax specific override, I guess.

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
	<key>scope</key>
	<string>
		source.php, source.sql
	</string>
	<key>settings</key>
	<dict>
		<key>indentParens</key>
		<false/>
	</dict>
</dict>
</plist>

Haven’t tested it though.

1 Like

#8

When i open file Default.sublime-package its opens in strange format

If i open in Notepad++ its opening more readable

How can i edit it?

0 Likes

#9

*.sublime-package == *.zip

Note:

  1. You should probably never edit one of the shipped sublime packages directly as any change gets lost with the next update.
  2. Furthermore you should override parts of the Default package only if you know what you are doing.

PackageResourceViewer can extract single files from a or the whole sublime-package. A file located in %APPDATA%\Sublime Text 3\Packages\Default would override the one from the packed *.sublime-package.

I’d argue it should be enough to create a My Indentation Rules.tmPreference in the User package with the content from my previous post.

1 Like

#10

For what it’s worth (what with me being the person that created the thing and thus biased), I would recommend OverrideAudit rather than PackageResourceViewer for a task like this (for people that want to undertake it):

  • It contains a command OverrideAudit: Create Override that allows you to create a single override in a manner similar to PackageResourceViewer
  • It does not contain the disastrous commands that will extract either a whole package OR every package, which is one of the best ways going to lock everything at a single version such that nothing can ever upgrade again
  • It gives you warnings when the files that you’ve overriden are changed at the source so that you know you could potentially face issues.

That last one alone would have saved several people from complaining about how ST4 was broken because they had overriden the entire Default package (wether by design or accidentally).

0 Likes

#11

As you recommend me i create file. How can i check, that this file is checked by sublime text 3 and setting is changed?

0 Likes

#12

If the contained setting was the root cause for invalid indentation, it should work now. I am not aware of any API to query such kinds of information.

0 Likes

#13

it would need to have the tmPreferences file extension, yours is missing the s at the end in the screenshot. If you open the ST console, you should see a line like generating meta info summary whenever you save the tmPreferences file

1 Like