Closed Bug 988155 Opened 11 years ago Closed 11 years ago

Option to detect indentation in source editor

Categories

(DevTools :: Source Editor, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 31

People

(Reporter: harth, Assigned: harth)

References

Details

Attachments

(1 file, 1 obsolete file)

Our source editor has default 4 space indentation, and no easy way to change this. I usually do 2 spaces depending on the code base. It would be nice to detect the indentation per file.
Assignee: nobody → fayearthur
Attached patch Detect indention pref, default on (obsolete) (deleted) — Splinter Review
This patch adds a default-on pref. When the pref is on, the devtools editor will detect the indentation (2-space, 4-space, tabs, etc.) of a file when it's loaded or when the the text is reset, and set the indentation preference of the editor to that.
Attachment #8402947 - Flags: review?(mihai.sucan)
The test there is basic, but I did test the indentation detection algorithm a lot. The algorithm there is one I came up with, but I tried it and two other algorithms on 300 random JS/CSS/HTML gist files and it correctly detected the indentation in 96% of the files. Good enough I think.
Comment on attachment 8402947 [details] [diff] [review] Detect indention pref, default on Review of attachment 8402947 [details] [diff] [review]: ----------------------------------------------------------------- Patch looks good and I'm liking indentation detection. This was bothering me. Thanks for the fix! ::: browser/devtools/sourceeditor/editor.js @@ +947,5 @@ > /** > + * A PreferenceObserver observes a pref branch for pref changes. > + * It emits an event for each preference change. > + */ > +function PrefObserver(branchName) { Why not use the same PrefObserver from styleeditor/utils ? Maybe move it to DevToolsUtils.js. ::: browser/devtools/sourceeditor/test/browser.ini @@ +34,1 @@ > skip-if = os == 'linux'&&debug # bug 981707 skip-if applies to vimemacs test, so please add the new detectindent script after skip-if.
Attachment #8402947 - Flags: review?(mihai.sucan) → review+
(In reply to Heather Arthur [:harth] from comment #4) > Thanks Mihai. Try: https://tbpl.mozilla.org/?tree=Try&rev=b03daa9a9289 ...That didn't go so well. Trying again? https://tbpl.mozilla.org/?tree=Try&rev=148449bab14d
(In reply to Heather Arthur [:harth] from comment #5) > (In reply to Heather Arthur [:harth] from comment #4) > > Thanks Mihai. Try: https://tbpl.mozilla.org/?tree=Try&rev=b03daa9a9289 > > ...That didn't go so well. Trying again? > https://tbpl.mozilla.org/?tree=Try&rev=148449bab14d Okay that also didn't go so well either. All the bc failures are due to crashes. I'm going to look for more memory leaks.
Pref listeners were causing memory leaks, so I took them out, to be figured out in a follow up bug. try without them: https://tbpl.mozilla.org/?tree=Try&rev=ea21b90e4c6a
Attachment #8402947 - Attachment is obsolete: true
Keywords: checkin-needed
Flags: in-testsuite+
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 31
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: