Community
Participate
Working Groups
The JavaScript editor inserts tabs for indentation and I cannot find a way to tell it to use spaces. I have looked in all the expected places in the preferences (i.e. General > Editors > Structured Text Editors, General > Editors > Text Editors, Web and XML > JavaScript Files > JavaScript Sources).
Changed Version field given new release numbering.
Created attachment 35359 [details] Adds a group to the js source preferences to manage tab vs spaces and tab width This patch adds a group to the source preference page so that the user can choose between tabs vs spaces indenting. Tab/spaces width can be specified as well. The feature is implemented in the attached TabsAutoEditStrategy and SourceViewerConfiguration
Thank you so much for patch. I will look into applying it. Using TabsAutoEditStrategy & SourceViewerConfiguration sounds like the right approach. Did you basically use what is done in the SSE editors as an example?
(In reply to comment #3) > Thank you so much for patch. I will look into applying it. Using > TabsAutoEditStrategy & SourceViewerConfiguration sounds like the right > approach. Did you basically use what is done in the SSE editors as an example? My impl. of AutoEditStrategy is simpler, I don't know if I'm missing something. Another difference is that the js editor does not use the sse so I had to do to make sure that the right configured tabs were used even when you select 2+ lines of code and shift right. In that case the customizeCommand of autoeditstretgy is not called so I make sure that the textWidget.setTabs(int) is called when tabs preferences are updated.
By the way, I notice now (using the latest release - 1.0.0.v200602062135 - so no patch involved) that everyitme you select one or more lines of text and press tab, everyting runs fine apparently, but the error log reports: Exception in notifyChanged() of LineStyleProviderForJava java.lang.IllegalArgumentException: Index out of bounds at org.eclipse.swt.SWT.error(SWT.java:2926) at org.eclipse.swt.SWT.error(SWT.java:2865) at org.eclipse.swt.SWT.error(SWT.java:2836) at org.eclipse.swt.custom.StyledText.redrawRange(StyledText.java:6203) at org.eclipse.wst.javascript.ui.internal.editor.JSLineStyleListener.redrawRegion(JSLineStyleListener.java:548) at org.eclipse.wst.javascript.ui.internal.editor.JSLineStyleListener.documentChanged(JSLineStyleListener.java:179) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:729) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:692) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:677) at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:754) at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1112) at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1119) at org.eclipse.jface.text.TextViewer.shiftRight(TextViewer.java:3857) at org.eclipse.jface.text.TextViewer.shift(TextViewer.java:3809) at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3531) at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:801) at org.eclipse.ui.texteditor.ShiftAction$1.run(ShiftAction.java:85) and so on ... Don't know if I should fill a bug for this. Eclipse SDK 1.3.2
Actually, I believe that additional bug you are seeing is bug 92962
Okay, I've looked over the patch some more. I noticed the TabsAutoEditStrategy attached itself as a preference listener to keep track of when the tabs for spaces. The problem is that I could not find where it removes itself as a preference listner. This could turn into memory leaks. I also noticed TabsAutoEditStrategy had a similar problem bug 105912 had. If I copied and pasted text that had a tab in the middle of it, I would lose everything that was before the tab character. Got any solutions for these issues? I will attach a patch I created that takes the same approach as the source editors. I think a difference in our fix approach is that instead of listening for a preference change, I am just checking the preference every time. The problem I have is that I cannot short circuit the shift right & shift left actions to check the preference each time because those actions are in the SourceViewer, which JSEditor does not subclass. So if the user changes the tab preference, the new preference is not picked up by shift right/left until after user closes and reopens the editor. So I guess both our solutions are not fully there yet.
Created attachment 36173 [details] patch to javascript.core & javascript.ui Here's my partial solution. See previous comment for more info.
I found a workaround to the problem with my patch (I basically add a preference listener in JSEditor that updates the indent prefixes when the preference changes) I also found a fix for bug 92962. Both fixes should be in this week's ibuild.
released for this week's ibuild
This is part of a mass update to close out all stale WTP resolved bugs from the 1.0.x and 1.5.0 timeframe. If you feel this bug was closed inappropriately, please reopen. Thanks, John Lanuti