1

I installed GNAT GPS 2017 and I would like it to indent my code with tabs using the same width as 4 space characters. I've gone into Edit->Preferences->Editor->Ada and tried all sorts of options (Use tabulations, default indentation 4, etc) but nothing seems to make it work:

  1. Opening existing file with tabs causes GPS to display tabs with 8 spaces wide instead of 4.

  2. Adding new code causes GPS to indent with 4 spaces but it inserts space characters instead of a single tab character.

Any ideas?

  • my current settings are "default indentation = 3" and "use tabulations". Let me check – Jean-François Fabre Nov 23 '17 at 15:10
  • so you want to keep the tabulations? – Jean-François Fabre Nov 23 '17 at 15:19
  • Yes I'd like all indentation to use tabs and NOT spaces. So when a line is indented it should be a single tab character and the width of indentation should be the same as 4 space characters –  Nov 23 '17 at 15:24
  • just checked, the tabulations are displayed as 8 chars no matter what (but the editor shows column 3 when setting indent 3). So that's a bug, not fixed in professional versions... – Jean-François Fabre Nov 23 '17 at 15:32
  • OK looks like 2 bugs, 1) "Default indentation" option is not applied, and 2) "Use tabulations" options is also not applied. –  Nov 23 '17 at 15:38
  • 2
    you shouldn't use tabulations in your source. Just remove them and replace by spaces. then all indentation will work. Their code parser doesn't support tabulations properly. – Jean-François Fabre Nov 23 '17 at 15:41
  • Well I would disagree, telling people not to use tabs is not a solution. If this is a real bug, they should test their code better. –  Nov 23 '17 at 15:49
  • Okay but you're getting the software for free so don't complain too much. (Our company is paying for the professional version). And tabs are evil. You'll get bitten at some point. – Jean-François Fabre Nov 23 '17 at 19:45
  • 1
    You don’t say _why_ you want to use tabs. (Mind, I don’t understand why anyone would want to use tabs in source code). – Simon Wright Nov 23 '17 at 19:56
  • Guys thanks for the answers, but the reason why I use tabs instead of spaces is rather irrelevant, i.e. many people use tabs, it's a personal preference. Yes I know I'm getting software for free, but that's not an excuse to ship buggy code. Displaying indentation properly is such a basic functionality that bugs like this should not exist. People evaluating GPS will find it rather worrisome, especially given the fact it is supposed to be used for writing high integrity software. You lead by example! –  Nov 24 '17 at 07:05
  • Ok, now that is said, just put an issue there (https://github.com/AdaCore/gps/issues ). Bugs exist in almost all piece of software. So complaining is a thing, contributing is another, just contribute making it better – Frédéric Praca Nov 24 '17 at 09:15
  • Visual Studio has an option to automatically substitute tabs for spaces- perhaps something could be added to GPS to do similar. To indent, you hit tab, but to back up, you can go a space at a time. Tabs are an arbitrary width, thus they violate most coding conventions. – theMayer Nov 28 '17 at 17:21

1 Answers1

2

I think that GPS is working as-designed; unfortunately, that isn’t the way you want it to work.

The Preferences > Editor > Ada > Default indentation setting (and the four settings following it) say what screen appearance is required (assuming a monospace font, of course) if you hit the TAB key in a line.

The Preferences > Editor > Ada > Use tabulations setting says whether the editor should use 8-column-width tabs when possible to achieve the above.

@Jean-François Fabre suggested that "Their code parser doesn't support tabulations properly" - I think this may be that Jean-François compiles with -gnaty (style checks), and one of the default style checks is that the file isn’t indented with tabs.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62