Author Topic: text replacement in source files?  (Read 6955 times)

divisortheory

  • Community Member
  • Posts: 21
  • Hero Points: 0
text replacement in source files?
« on: December 05, 2007, 03:21:24 am »
In C++ files, whenever I type "sizeof" in all lowercase letters, SlickEdit automatically converts it to "SIZEOF" in all uppercase letters.  I find this very peculiar since sizeof is actually a C++ keyword, and SIZEOF is not.  Can anyone tell me why this might be happening and how I can turn it off?

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: text replacement in source files?
« Reply #1 on: December 05, 2007, 02:46:44 pm »
My first guess is that this is auto-completion at work. Check you settings for Tools > Options > File Extension Setup, make sure the c extension is selected and pick the Auto-Complete tab. Uncheck "Auto select unique items".

Now trying typing "sizeof" again. You should be prompted with a list of completions which should contain just the single element "SIZEOF". Without seeing your code, I can't say where it is picking up that symbol.

If this didn't work, something else is going on.

divisortheory

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: text replacement in source files?
« Reply #2 on: December 05, 2007, 04:48:00 pm »
Thanks, I'll give this a shot when I get home later.  If it doesn't work I'll make sure to post my code (it's very small), it didn't occur to me that #includes might have been affecting it.

lambertia

  • Senior Community Member
  • Posts: 382
  • Hero Points: 14
  • I have nothing sufficiently witty to say.
Re: text replacement in source files?
« Reply #3 on: December 06, 2007, 08:47:04 pm »
Hi SE team.

This thread raises a topic I've always meant to ask. Why isn't auto-completion case sensitive? Is there an option to make it so? I would have thought that once "si" was typed "SIZEOF" should be excluded. This would reduce the number of false hits that I get exponentially!

Cheers,
--
Greg.

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: text replacement in source files?
« Reply #4 on: December 06, 2007, 10:32:14 pm »
Hmm...actually, auto-completion appears to be case-sensitive. At least in the testing I just did. Can you send me a screen shot with a mixed case match from auto-completion.

Based on that, my explanation to the original post is completely wrong. The support guys think they've hit this before and we're trying to find it in the tracking system.

codehelp_complete seems to have some issues with case, though. This is invoked by pressing Ctrl+Space in CUA emulation. We've seen cases of that turning "sizeof" into "SizeOf" and "SIZEOF". We're still trying to figure that one out. I didn't think that was the reported issue since he said "automatically converts".

We should probably look at making case-sensitivity an option for these features, because we are constantly beset with conflicting feature requests. Some want it to be case insensitive since they can't remember the case: was it "xFooDog" or "xfooDog"? Others want strict case interpretation to cut down on bogus matches.

I like case insensitivity because I don't believe variables should ever differ just on the case used. I think it's crazy that a language would think that "foo" and "FOO" are different symbols. Can you imagine how much time a bug like that would take to track down. If you can't, you probably dream in color too.

Anyway, we'll keep looking into this. Some code samples and very precise instructions on how to replicate the issue would be greatly appreciated.

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Re: text replacement in source files?
« Reply #5 on: December 06, 2007, 11:41:36 pm »
Actually, one coding style in C does this:

#define MANGLE(x) (x + 4)

typedef struct Mangle_struct {int a; char c} Mangle;

Mangle mangle;

ie all caps for preprocessor variables, initial caps for typedefs, and lowercase for real variables.  And commonly using the same name with just caps different between the variable and the type.  Yuk!  But you do run across code like this still.

evanratt

  • Senior Community Member
  • Posts: 300
  • Hero Points: 23
Re: text replacement in source files?
« Reply #6 on: December 07, 2007, 09:54:58 pm »
This sounds very much like the issue that is mentioned in this thread:
http://community.slickedit.com/index.php?topic=1848.0

It still happens to me occasionally, and every time it does I double-check and make sure that "Auto select unique items" is disabled in my extension options (it is, and always has been). I still haven't been able to come up with any sort of a reasonable example case to submit, and because the tag it decides to autocomplete with is usually from a completely unrelated module in the code, I doubt I'll be able to find an example case without submitting our entire code base (I'm sure my company would LOVE that).

As an aside, it does not seem to be case sensitive when it does this unwanted auto-completion.

divisortheory

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: text replacement in source files?
« Reply #7 on: December 08, 2007, 11:08:48 pm »
Alright, well auto-completion is DISABLED, I just verified this, and it just happened to me again.

I notice a few interesting things, and I believe I've isolated the problem:

1) If I type slow enough to view the auto-completion dropdown box, it goes like this:

SIZE_MAX
size_t
SIZEOF
SIZEOF_DOUBLE
...

"sizeof" appears nowhere on the list.  This is in a CPP file, but when I select CPP from the file type box, it just says "refers to -> c".

So sizeof doesn't even appear to be an option.  I can get sizeof to appear in the list, but I have to do the following steps:

1) Press enter to accept SIZEOF.
2) Backspace over SIZEOF, and the space before that, and the comma before that.
3) Click the mouse anywhere in the editor window to clear the function parameter info for the macro I'm currently in.
4) Click the mouse again at the end of the line that was causing the problem
5) Type the comma again, followed by the space, followed by sizeof.

I can then get the problem to happen again if I take the following steps:

1) Backspace over sizeof, the space, and the comma
2) Press Ctrl+Shift+Space to bring up the parameter helper for the macro that I'm in
3) Type the comma, then the space, then sizeof.

The difference between the case where it works and when it doesn't work is that when it doesn't work, there is already a tooltip being displayed for the function parameters of the function I'm in.

Example:

#define min(a, b) (((a) < (b)) ? (a) : (b))

//Type the following

int result = min(5, sizeof(int));

After typing the first open parentheses, you get a popup for min telling you what the parameters are.  Now the problem will happen.  As long as the tooltip for min is NOT being displayed, the problem will not happen.
« Last Edit: December 08, 2007, 11:11:27 pm by divisortheory »

divisortheory

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: text replacement in source files?
« Reply #8 on: December 11, 2007, 05:40:56 am »
I've been playing with this some more and discovered that you can cancel the tooltip with the escape button.  So consolidated list of steps to reproduce are:

1) Define a C++ macro in your code
2) Generate tags
3a) Begin typing in a call the macro from step 1, and once you have typed the open parentheses for the macro, make sure the parameter helper tooltip for the macro is up.  If it is not, press Ctrl+Shift+Space to bring it up.
3b) Begin typing in a call the macro from step 1, and once you have typed the open parentheses for the macro, make sure the parameter helper tooltip for the macro is NOT up.  If it is up, press Escape until it has disappeared.
4) Begin typing sizeof as one of the parameters to the macro.

If you follow step 3a, sizeof does not appear in the list and the auto-complete forces you to use SIZEOF.  If you follow step 3b, everything works correctly.

This is on Ubuntu Gutsy Gibbon, btw.


hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: text replacement in source files?
« Reply #9 on: December 11, 2007, 09:39:38 am »
@divisortheory: I think this has been addressed in hotfix r21 (which unfortunately seems to be broken at the moment).
Try the upcoming fixed hotfix appearing soon (probabaly today).
HS2

divisortheory

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: text replacement in source files?
« Reply #10 on: December 12, 2007, 12:05:29 am »
Thanks.  Although I find it odd that they listed the solution as "do not display auto-complete while inside a macro parameter list".  That's not what I was hoping for at all, I was hoping they would just add the keywords to the list of what's already displayed.  Keywords come up when there is no tooltip being shown, why not when there is a tooltip being shown?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2860
  • Hero Points: 434
Re: text replacement in source files?
« Reply #11 on: December 12, 2007, 02:51:17 pm »
For the record, the hot fix text says:

Quote
    Fix issue where user was typing "sizeof" and auto-list-parameters was
    completing it as the only visible matching symbol in his workspace which was
    SIZEOF.  The solution is to not permit auto-list-parameters in macro
    argument lists.

Auto-list parameters is different from auto-complete.  Please refer to the other thread:  http://community.slickedit.com/index.php?topic=2299.0 for a detailed description.

And finally, try the fix, it does solve your issue.

divisortheory

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: text replacement in source files?
« Reply #12 on: December 12, 2007, 03:03:16 pm »
Thanks.  Well, I'm actually still evaluating SlickEdit so I don't think I can apply the hotfix.  I'm probably going to go ahead and purchase after the expiration period is up though, so I'll try it then.