pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.62k stars 518 forks source link

Correct Indentation is not working 100% #1185

Closed fireymerlin closed 2 months ago

fireymerlin commented 2 months ago

I use ZBS to write lua programs to manipulate data files for the World of Warcraft (WOW) game. Recently, WOW stopped indenting their data files, so I'm using ctrl-a, ctrl-I a lot. Frequently, ZBS is not correctly all of the indentation. Here is an example from a file that has 236 lines. The following are lines 118 thru 148. Everything above this was indented correctly. Lines from 172 to eof were also indented correctly. ["sets"] = { ["SCONLEY4"] = { }, ["Flold-Mankrik"] = { }, ["Hunter"] = { "Feed_Me", "GFW_FeedOMatic", "Lemmos_RefillAmmo", "ClassicHunterPetInfo", "PetAbilities", "PetHealthAlarm", "Tamed", }, ["SCONLEY5"] = { "FarmHud", "FarmHud_QuestArrow", }, ["Enchanting"] = { }, ["Libraries"] = { "Ace3", "LibCompress", "LibDBIcon-1.0", "LibDropdown-1.0", "LibNotify-1.0", "LibProfessions", "LibQTip-1.0", }, ["Zords-Skull Rock"] = {

pkulchenko commented 2 months ago

Can you show an example on what you mean by incorrectly? A full file would be helpful as well, as I can't reproduce it on this fragment.

fireymerlin commented 2 months ago

This file was opened in ZBS and had no indentation. I use ctrl+a and then ctrl+i. I then copied and pasted into pastebin. https://pastebin.com/ARTWs7Ju

fireymerlin commented 2 months ago

Look at the line with ace3 on it and some of the lines following that. They are not indented correctly. Let me know if there are options that would cause that.

pkulchenko commented 2 months ago

Yes, this is kind of by design. If the strings or lines within comments start in the very first column, they are not going to be reformatted (assuming that's the position you want to keep it in). I realize that it's not always the case, but if you add even one space in front of those lines, they will be re-formatted as expected. See the fragment starting here; you can play with its logic to see what works better.

pkulchenko commented 2 months ago

It is not consistent. All of the lines started in column 1. The first 100 or so were indented, the rest were not. It is out of my control since I do not create the file.

It's consistent based on the explanation above, as only strings and comments that start in the first column are not re-indented. If you don't like this behavior for strings, you can comment out this line and all strings should be re-formatted as well.