Autoformat (Ctrl+T) screwing up quoted text

I use printf a lot and other quoted (constant) strings. Daily, the IDE will reformat these quoted strings. I have to go back and fix them when I see the output format has been changed. I set it up the way it needs to be and I don't want it "fixed" for me!

Here are two example. There are thousands!

Example 1:
What it should be (and I keep fixing it and it keeps getting destroyed):
Serial.printf("CO2 Sensor TX to %i, Sensor TX to %i\n", MHZ_RXPin, MHZ_TXPin);

What it becomes all by itself (probably because of Ctrl+T):
Serial.printf("CO2 Sensor TX to % i, Sensor TX to % i \n", MHZ_RXPin, MHZ_TXPin);

Example 2:
What it should be (and I keep fixing it and it keeps getting destroyed):
homeTime.setLocation("Asia/Manila");

What it becomes all by itself (probably because of Ctrl+T):
homeTime.setLocation("Asia / Manila");

Please range in Ctrl+T to NOT change quoted strings. They are the way the need to be and are not subject to "fixing"!!!

Using 1.8.19, the current release as of this posting.

Mike Morrow

I am still using IDE 1.8.13 as I can see no reason to upgrade it and I do not see that problem

You are blaming Auto Format for the problem, which should be easy to prove because it does not happen unless you invoke it manually

Please try putting the single line

homeTime.setLocation("Asia/Manila");

in the IDE with nothing else then invoking Auto Format. Does the problem occur

I don't see the issue on a Mac with 1.8.19 nor in 2.0x

are you sure you used proper double quotes (here is a free pair to try "xxx", don't thank me I've plenty spare ones :slight_smile: ) and not some other UTF8 variant?

It is intermittent. Usually happens one per day or two days. Intermittents are very difficult to find and reproduce. It has not happened today. It also happened on previous releases. I cannot reproduce this at will. I am assuming it is Ctrl+T but am not sure. That's for someone who knows the guts of this IDE to figure out (I hope).

Don't ever press CTRL-T (or check carefully when you do) and you will know for sure.

When that happens to me, it is always due to a typo/code error, like a missing brace, quote character, or something else.

I've seen this happening if you have some sort of a syntax bug in your code and press cmd-T

for example if you are missing an opening " and have other string further down, and you press ctrl-T then it does create a big mess indeed because the parsers does not see the bug and sees as text (likely) what's in between the actual quotes.

For example try pressing ctrl-T on this:

void setup() {
  Serial.begin(115200);
  Serial.print(F(Ooops I forgot the opening quote"));
  Serial.printf("CO2 Sensor TX to %i, Sensor TX to %i\n", MHZ_RXPin, MHZ_TXPin);
}

void loop() {}

you'll see that the second line gets screwed.

When lines are not next to each other and you don't see the mess when you press cmd-T, then you compile and get warned about the issue on the first line. You add the missing double quote and press cmd-T again which fixes the compiling bug but it's too late, you have already formatted the text further down in the wrong way...

1 Like

That could surely be what is happening. Something far away causing a problem. I will watch more closely for just this situation in the future. Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.