Closed
Bug 910183
Opened 12 years ago
Closed 11 years ago
highlight trailing whitespace
Categories
(DevTools :: Source Editor, defect, P3)
DevTools
Source Editor
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 29
People
(Reporter: fitzgen, Assigned: bendecoste)
Details
Attachments
(1 file, 3 obsolete files)
|
353.91 KB,
patch
|
anton
:
review+
|
Details | Diff | Splinter Review |
Every time you hit RETURN in the scratchpad, it maintains your indent level. Therefore, if you want to have a blank line between two lines of code, you often end up with trailing whitespace on the blank line, and won't realize it until you save your scratchpad and open it in your normal editor.
We should highlight this whitespace so people can catch it earlier. And maybe delete trailing whitespace on save too.
Comment 1•12 years ago
|
||
Highlighting trailing whitespace is really easy to do with CodeMirror.
OS: Mac OS X → All
Priority: -- → P3
Hardware: x86 → All
Version: unspecified → Trunk
Hello! First time contributor, I implemented this functionality tonight. In it's current state it looks like http://i.imgur.com/CmOZriE.png
I'm not much of a designer, opinions?
Comment 3•12 years ago
|
||
Nice. How about using a light red background color? Most editors I've used do something similar.
Comment 4•12 years ago
|
||
Thanks Ben!
IMHO, this should be an Editor thing—not just Scratchpad thing. Other clients (debugger, styleeditor and or addons) might want to use that feature as well.
| Reporter | ||
Comment 5•12 years ago
|
||
Awesome work! Since you haven't uploaded a patch, I can't tell how generic your solution is, but this should definitely be fixed at the source editor level.
If you have more questions about the source editor, Anton is a good person to ask (here or on irc).
Cheers!
Component: Developer Tools: Scratchpad → Developer Tools: Source Editor
Attachment #8336511 -
Flags: review?(anton)
added a patch .. pretty new to hg so sorry if i botched that, still need to fixup the styling whenever I have a chance
Comment 8•11 years ago
|
||
Comment on attachment 8336511 [details] [diff] [review]
add whitespace to editor
Review of attachment 8336511 [details] [diff] [review]:
-----------------------------------------------------------------
::: browser/devtools/sourceeditor/codemirror/activeline.js
@@ +36,5 @@
> cm.addLineClass(line, "wrap", WRAP_CLASS);
> cm.addLineClass(line, "background", BACK_CLASS);
> cm.state.activeLine = line;
> }
> +})();
Why was this file changed?
::: browser/devtools/sourceeditor/codemirror/mozilla.css
@@ +69,5 @@
> font: message-box;
> +}
> +
> +.cm-trailingspace {
> + trailingspacebackground-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAACFJREFUCNdjPMDBUc/AwNDAAAFMTAwMDA0OP34wQgX/AQBYgwYEx4f9lQAAAABJRU5ErkJggg==);
What is 'trailingspacebackground-image'?
::: browser/devtools/sourceeditor/codemirror/trailingspace.js
@@ +1,1 @@
> +(function() {
You need to use two spaces instead of tabs in this file and everywhere else.
Attachment #8336511 -
Flags: review?(anton)
Attachment #8338214 -
Attachment is patch: true
Attachment #8336511 -
Attachment is obsolete: true
| Assignee | ||
Comment 10•11 years ago
|
||
updated patch .. I don't have windows or mac to check styling there, hoping somebody could give me a hand there (I didn't add that png to those dirs yet)
Updated•11 years ago
|
Assignee: nobody → bendecoste
Comment 11•11 years ago
|
||
I took previous patch, replaced an image with a base64 string and added a test case.
Attachment #8338214 -
Attachment is obsolete: true
Attachment #8359506 -
Flags: review?(mihai.sucan)
Comment 12•11 years ago
|
||
Comment on attachment 8359506 [details] [diff] [review]
WIP 2
Review of attachment 8359506 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good.
This is not a very common option enabled by default in editors (at least, not as far as I know). Shouldn't we provide a pref to allow the user to disable the highlighting of trailing whitespace?
Also, this is showing we care about trailing whitespaces, but the editor is 'happy' to leave such whitespace. Type |if (foo) {<Return><Return>|. We should remove the trailing whitespace when you add new empty lines.
(I wouldn't like the editor to remove any trailing whitespaces on save. That can cause undesired changes in files, on lines the user never touched.)
Attachment #8359506 -
Flags: review?(mihai.sucan) → review+
Comment 13•11 years ago
|
||
Thanks!
> Shouldn't we provide a pref to allow the user to disable the highlighting of trailing whitespace?
Agreed, I'll make a pref (false by default) before landing. Then we can add a View item for it in bug 953206. Also filed bug 959803 for not adding trailing space on new lines.
Comment 14•11 years ago
|
||
Added a pref (off by default).
Attachment #8359506 -
Attachment is obsolete: true
Attachment #8360030 -
Flags: review+
Comment 15•11 years ago
|
||
Whiteboard: [fixed-in-fx-team]
Comment 16•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 29
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•