When using backticks in a JavaScript file such as :
var name = 'Tom';
var greeting = `hello my name is ${name}`;
PhpStorm does all sorts of weird auto-formatting that breaks the file.
Backticks randomly appear or disappear, commenting the rest of the file.
I've disabled the 'insert pair quotes' option in Settings but the problem still persists.
Is there a way to disable auto-formatting for backticks in PhpStorm version 2016.1.2?
I have the same Problem with template strings. In the example, I added a backtick and it disappears when moving the cursor. Not if you use the mouse. example gif
My current workaround is to use normal concatenation and let PhpStorm convert it by clicking on the lightbulb.
I temporarily switched to using Sublime Text because my Macbook Air's 4 GB of RAM were not enough for Phpstorm.
The backtick problem still occurs with Sublime Text.
This makes me think that the problem is more related to OS X than Phpstorm.
Also the developer from Jetbrains was not able to reproduce the problem when I posted a bug there.
Because of the Macbook Pro 2016 debacle, I switched back to windows and the problem does not occur anymore for me. If anyone has a better answer I will update this.
Related
So we have input text component which we are using it as a contact form where its working normally when we test it on Web/Desktop version. The issues occurs whenever we use test on iPhone its not accepting the the value. eg; O'Connor.. or whatever that goes with apostrophe.. I have used the multiple encoding ways but it still no use.
Any help would be really appreciated..
This may or may not be related to your issue, but I discovered today that React Native's TextInput feature, on iOS, handles apostrophes and quotation marks in a strange way (which I have not observed with other punctuation). When you enter either character, it calls onSelectionChange twice before it calls onChangeText, which caused very strange behavior in a custom text input component. Possibly this is a result of some auto-formatting feature baked into iOS, and if so that might be part of your issue, even in a React web environment.
I know this is about 10 months old but I actually just ran into a similar issue. I think this smart quotes issue.. IOS is changing the apostrophe to a right-single quote.
Try this var goodQuotes = badQuotes.replace(/[\u2018\u2019]/g, "'");
and for more information I got it from here.
When I am editing a JavaScript file inside VSCode and try using the backticks (`) it won't auto close. I want to have the same auto-closing feature that I have with the quotation marks, where if I type " I get:
"|"
(| = my cursor)
I have tried disabling all my extensions and that didn't solve it. If I try it inside Atom it works just fine.I'm using a Belgian keyboard layout on Mac.
A now-deleted answer referred to this fixed bug, but unfortunately for me, typing a space after the backtick (as described in the fix) just leaves me with a backtick and a space.
I haven't tried to find a way around this, but at least on my system (set to German) the behavior described seems to come from the fact that by default the backtick (`) is a dead key, meaning it will not produce a character until the next key is hit. Funnily enough, the backtick that you see on screen is thus actually created because VSCode tries to auto-complete the backtick (with another backtick), but the initial character is swallowed (because there is no such thing as an accented accent, which is what that key is generally used for).
If I type a space after the backtick, it gets auto-completed though. Running VSCode 1.36.0 on MacOS.
I hope my explanation is clear enough.
Setting "editor.autoClosingQuotes": "always" in VSCode settings fixed this for me.
EDIT: After using this for a couple of weeks it got really annoying always deleting the second quote when it added it even in inappropriate places, like at the beginning or middle of words. This is still the best solution I know of, but it's not perfect.
I love Sublime Text, it's my favorite code editor, but, sometimes inexplicable things happen (and that's not very often). My problem here is that I can't type the > symbol when I'm writing JavaScript. When I try to type >, it shows me an alert:
Could not find a definition
That's very annoying, especially when I want to write modern JavaScript, for example, when I write a function like this:
const myFunction = () => {
console.log("Hello world!);
}
I'm running Sublime Text 3 (stable channel) Build 3126 on OS X El Capitan. Is there a way to change the keybinding or something similar?
Edit: I'm using a French Canadian Keyboard, it mean that I have to hold alt before typing >
i think your problem can be solved by:
1- look if your preferences are correct, here there is a link with help:
Sublime Preferences
2- by using Atom.. (even looks the same, and have a huge community behind it)
I am developing a front end of a web app using NetBeans IDE 7.0.1. Recently I had a very nasty bug, which I finally fixed.
Say I have code
var element = '<input size="3" id="foo" name="elements[foo][0]" />';
$('#bar').append(element);
I noticed that something gone wrong when I saw that size attribute doesn't work in Chrome (didn't checked in other browsers). When I opened that element in Inspector, it was interpreted as something like
<input id=""3"" name=""elements[foo][0]""
size=""foo"" />
Which was rather strange. After manually retyping the element string character-in-character, the bug was gone. When I undo'ed that change I noticed that Netbeans alerted me about some Unicode characters in my old code. It was \u200b - a zero width spaces after each '=', between '][' and in the end of the string. So the string appeared normal because zero width spaces wasn't displayed, but after escaping them my string was
'<input size=\u200b"3" id=\u200b"foo" name=\u200b"elements[foo]\u200b[0]" />\u200b'
Now where the hell did I get them?
I'm not sure where did I copied the code of element from, but it's definitely one of the following:
Other pane of Netbeans Editor with HTML template file;
Google Chrome Inspector, 'Copy as HTML' action;
Google Chrome source view page (very doubtfully).
But I can't reproduce the bug with neither of that.
I use Netbeans 7.0.1 and Google Chrome 13.0 under Windows 7. No keyboard switchers or anything like it is running. Also I'm using Git for version control, but I didn't pulled that code, so it is very unlikely that Git is to blame. It can't be a stupid joke of my colleagues, because they are quite well-mannered.
Any suggestions who messed up my code?
Here's a stab in the dark.
My bet would be on Google Chrome Inspector. Searching through the Chromium source, I spotted the following block of code
if (hasText)
attrSpanElement.appendChild(document.createTextNode("=\u200B\""));
if (linkify && (name === "src" || name === "href")) {
var rewrittenHref = WebInspector.resourceURLForRelatedNode(node, value);
value = value.replace(/([\/;:\)\]\}])/g, "$1\u200B");
attrSpanElement.appendChild(linkify(rewrittenHref, value, "webkit-html-attribute-value", node.nodeName().toLowerCase() === "a"));
} else {
value = value.replace(/([\/;:\)\]\}])/g, "$1\u200B");
var attrValueElement = attrSpanElement.createChild("span", "webkit-html-attribute-value");
attrValueElement.textContent = value;
}
It's quite possible that I'm simply barking up the wrong tree here, but it looks like zero-width spaces were being inserted (to handle soft text wrapping?) during the display of attributes. Perhaps the "Copy as HTML" function had not properly removed them?
Update
After fiddling with the Chrome element inspector, I'm almost convinced that's where your stray \u200b came from. Notice how the line can wrap not only at visible space but also after = or chars matched by /([\/;:\)\]\}])/ thanks to the inserted zero-width space.
Unfortunately, I am unable to replicate your problem where they inadvertently get included into your clipboard (I used Chrome 13.0.782.112 on Win XP).
It would certainly be worth submitting a bug report should your be able to reproduce the behaviour.
This happened to me when I copied source code from another site into my editor.
If your using visual studio code or Atom editor, this will highlight those pesky characters zero-width space \u200b) etc.
VSCode: https://marketplace.visualstudio.com/items?itemName=nhoizey.gremlins
Atom editor: https://atom.io/packages/highlight-bad-chars
Sublime Text: https://packagecontrol.io/packages/Gremlins
As Mr Shawn Chin has addressed it already. I just happened to replicate the issue while I was copy pasting jquery code from a webpage.
When it happened: Copying text from Google Chrome Version 41.0.2272.118 m ( not tested with other browsers ) to Dreamweaver code window. This copied unwanted characters along the code like this happening here
you copied text from a webpage as
$('.btn-pageMenu').css('display','block');
behind the scenes, this is what makes that line
<code><span class="pun"></span><span class="pln">$</span><span class="pun">(</span><span class="str">'.btn-pageMenu'</span><span class="pun">).</span><span class="pln">css</span><span class="pun">(</span><span class="str">'display'</span><span class="pun">,</span><span class="str">'block'</span><span class="pun">);</span></code>
Copied to an advanced editor like those you mentioned or Dreamweaver gives errors in browser, probably failing of javascript code too
Uncaught SyntaxError: Unexpected token ILLEGAL
Solution: When it happens, embrace the worth of notepad until this gets fixed by the big guys. It is more related to the editor then the browsers.
After longer than 6 years I am getting the same issue but I am able to reproduce it.
I am learning JavaScript from this blog which contains code snippets. Whenever I copy all the code from a snippet and paste it into the JavaScript editors of JS Fiddle or JS Bin I get some red tokens spread into the code. Here are screenshots of the first code snippet from the above blog post in the JS Fiddle and JS Bin. Hovering the mouse over one of these red tokens shows up the tip: "\u200b" (the zero-width space).
I'm working on Linux Ubuntu 16.04 and if I paste the code into one of my editors (Atom 1.22.1 or Geany 1.32) and then open the file in web browsers, I get the following errors in the console:
Chrome 63 --> SyntaxError: Invalid or unexpected token
Firefox 57 --> SyntaxError: illegal character
I hope this may help a bit to clarify why these zero-width spaces get copied into the clipboard.
I have similar issue with '\u200b' zero-width space character in my current project. I need to work on JSON object returned from server. Email object with '[at]' need to be replaced with '#' character. Surprisingly, several of the objects had the email address littered with 'space' in and around the '#'.
Long story short, I checked using Postman and scrutinised the returned JSON as RAW. Here is the raw example:
johndoe[at]\u200bxyz.org
I could see the character '\u200b' on all those trouble email address. Since only few email addresses affected, I removed the character manually. The server gets the data from Sharepoint.
I have been using Eclipse for some weeks now and I start getting used to it.
However, one thing really annoys me:
When editing JavaScript (I didn't try any other language yet), the editor window keeps jumping to the start of the document I am editing.
This mostly happens when the code currently contains syntax errors and mostly while / after deleting lines.
Especially constructs like { = and sometimes unterminated strings / comments seem to cause this problem.
When it happens, only the view scrolls to the top of the document - the cursor stays where it was before the "jump" occurred.
Anyone having an idea on how to fix this?
I believe the problem described above is related to this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318095
The work around is to disable the "Link with Editor" option from the Project Explorer. Which is to say make sure the icon with two arrows facing in opposite directions at the top of the file tree is not enabled. Disabling this option resolved the issue for me.
Looks like a problem with the implementation of the JavaScript editor. Most probably the jump occurs when the JavaScript-Parser is not able to parse your document and throws an exception. You might consider to report a bug to the eclipse project (maybe there is already such a report?).
As a workaround you might consider to adapt your way of typing the code a bit. Try to write the code in a way that does not confuse the parser (for example it might help to immediately close a newly created comment and THEN write the content instead of open the comment, write the content and finally close the commend). Same for strings, blocks ...
I am having the same problem. I had this line of code in my file and I could consistently reproduce the issue:
$.preload(preloadImages
, {
base:assetsUrl+'b/images/',
ext:'.png'
});
I changed it to the following and I no longer have the problem.
$.preload(preloadImages, {
base:assetsUrl+'b/images/',
ext:'.png'
});
I get this Phenomenon, when i'm editing in a Java-Class while still residing in a Debug-Process. The Debugger recognises the Change and reevaluates the Code and jumps back in order to be able to reexecute only the changed Code.
Hii i got solution goto
Window->Preferences->search autosave
and disble it and hit apply and close button.
this worked for me !