0

I'm trying to override the toString() method for an equation expression object, but Eclipse seems to delete the ^ symbol. I keep on retyping it and Eclipse highlights the symbol in yellow and then even with just moving the cursor around results in the symbol being automatically deleted, ending up with return variable + "" + power.tostring();

So whenever I modify something in this file, I have to keep in mind that the symbol gets deleted and type it again. How can I solve this? Or even better, is there a way to superscript power.toString() when printing to console?

@Override
public String toString() {
    if (reducedExpression) {
        return variable + "^" + power.toString();
    }
Raul
  • 21
  • 3
  • 1
    Are you actually typing the regular `^` symbol or some other unicode symbol? There is no way to just write arbitrary text in superscript which would work in all consoles and all encodings whatsoever. – Zabuzard Oct 27 '21 at 13:38
  • 1
    You might need to hit space bar after typing the symbol to type it by itself or copy it from character selector. – LMC Oct 27 '21 at 13:38
  • That sounds like you have _Completion overwrites_ mode enabled (in the preferences _Java > Editor > Content Assist_), which means the yellow marked characters will be overridden when choosing a proposal (enable [_Disable insertion triggers except 'Enter'_](https://stackoverflow.com/a/53872999/6505250) to avoid accidental selecting a proposal by hitting space). It is unclear to me how to reproduce your specific sample. Please tell which keys have to be hit, show a screenshot with the highlighted characters and tell the Eclipse version you have. – howlger Oct 28 '21 at 08:14
  • 1
    @howlger I can get this behaviour on macOS by typing the "combining accent" character for a circumflex accent (⌥+i on the Mac keyboard) - it is merged with the next character if it is valid, otherwise removed. – greg-449 Oct 28 '21 at 10:41
  • 1
    @LMC thanks a lot, just hitting the space bar solved my problem. – Raul Oct 29 '21 at 16:04
  • @howlger I tried enabling "Disable insertion triggers except 'Enter'" but that kept the ^ symbol highlighted and then when saving the file the symbol was automatically deleted. – Raul Oct 29 '21 at 16:04

0 Answers0