| Summary: | add "insert spaces for tabs" function to sse editors | ||
|---|---|---|---|
| Product: | [WebTools] WTP Source Editing | Reporter: | Andrey Loskutov <loskutov> |
| Component: | wst.sse | Assignee: | Amy Wu <for.work.things> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | daniel_megert, for.work.things, zaphod |
| Version: | 0.7 | ||
| Target Milestone: | 1.0 M6 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
| Bug Depends on: | 82296 | ||
| Bug Blocks: | 71221, 97729 | ||
| Attachments: | |||
|
Description
Andrey Loskutov
This happens when you type, if you use the format command then the preferences will be used. However this is of cause wrong. Kit ... sounds like something you would know about. Is there an easy way for us to fix this, and be consistent with base editors? The "Indent using tabs" preference on the HTML Source Preferences page is for "Formatting" only. Note that all the "Line width", "Split multiple attributes", "Indent using tabs", and "Clear all blank lines" preferences are inside the "Formatting" groupbox. If you don't want the tab key to tab 4 spaces, you should change the "Displayed tab width" preference on "All Text Editors" Preferences page to 1 for all Eclipse editors, and change the same preference on "Structured Text Editors" Preferences page to 1 for all Structured Text Editors (including HTML, JSP, XML Editors). Hi, Kit, why this bug is marked as invalid? The fact is, that if I type "TAB" key in jsp editor, *tabulator* character appears in source code (and I will only 4 spaces). I can set any preference in any place - this behavoir is still there. <bold> I won't see tab characters in my source code - but currently they are there... </bold> I'm agree with you, that "tabs" preferences is for code *formatting* - but the bug was not against wrong prefrerences, but against editor behavoir. Probably my first description was not good enough, but in the bug summary I wrote: "HTML editor uses always tabs for identation" - and this bug ist still not fixed. I'm sorry Andrei, I don't quite understand the problem. Do you want to see 4 spaces (instead of the invisible tab character) inserted into the HTML Editor when you press the tab key on the keyboard? Exactly, e.g. like Java editor this does, if in "Java->Code style->Formatter" preferences the "use tab character" is not selected (this is similar to "HTML files->HTML source->Formatting->Ident using tabs" preference). It will be better if inserted spaces count value will match any one of existing preferences for "tab width", either "All text editors -> Displayed tab width" or "Structured text editors -> Displayed tab width" or whatever. Ah, I learned a new function! That "tabs to spaces" function is specific to the Java Editor only. That function is not available in the Eclipse Text Editor, PDE Editor, or any of the Structured Text Editors. If we request that function to be moved from Java Editor to the Platform UI/Text level, then all subclasses of TextEditor will benifit from that. Please open a separate bug against the Platform UI/Text component. Hi Kit, I have created bug 82296 as requested in your comment #7. changing the summary to more accurately describe the issue Ok, I have a solution that will insert spaces for tabs every time you hit the
tab key. However, it is different than what the Java editor provides. Java
editor now has a preference "Tab key indents the current line" (Java->Editor-
>Typing tab) what it does is if you have it unchecked and you hit the tab
key, spaces are inserted. My solution does the same. The difference,
however, is that if you select multiple lines (or even if you select 1 whole
line) and then hit the tab key, the Java editor will still add spaces. My
solution, however, does not (it will just add a tab character)
Codewise, the difference is that Java editor creates an Indent Action that is
tied to the Tab key, versus my solution is tied to the AutoEdit function and
all it does is replace the tab key with space keys.
> The difference, > however, is that if you select multiple lines [...] > and then hit the tab key, the Java editor will still add spaces. > My solution, however, does not (it will just add a tab character) But then this is not really a good solution for this bug, because I would expect exactly the described behavoir of Java Editor for *any* number of selected lines, if I hit the "tab" in JSP file. I work in Eclipse on both Java and JSP code, and it would be very annoying if they would have different behavoir for really *basic* text operations. Please do not implement such partial solution. BTW, what is about bug 82296? Okay, I think i'm pretty close to solving the multiple lines problem (the solution involves overriding the shift left/shift right) Just to be clear, is your main concern that you do not want tabs to be inserted at all? I had misunderstood the Java->Editor- >Typing->"Tab key indents the current line" preference. It does not control whether or not spaces are replacing tabs characters. It's more about the Indent action, which sse editors really don't have at the moment (it only provides indentation when formatting, or indent 1 spot only) As for bug 82296 according to the bug, it looks like the base text team is not going to try to push it down for 3.1. > is your main concern that you do not want tabs to be inserted at all?
Hi Amy, this is the point.
Created attachment 22276 [details]
org.eclipse.jst.jsp.ui.patch
Created attachment 22277 [details]
org.eclipse.jst.jsp.ui.tests.patch
Created attachment 22278 [details]
org.eclipse.wst.css.core.patch
Created attachment 22279 [details]
org.eclipse.wst.css.ui.patch
Created attachment 22281 [details]
org.eclipse.wst.html.core.patch
Created attachment 22282 [details]
org.eclipse.wst.html.ui.patch
Created attachment 22283 [details]
org.eclipse.wst.html.ui.tests.patch
Created attachment 22284 [details]
org.eclipse.wst.javascript.ui.patch
Created attachment 22285 [details]
org.eclipse.wst.sse.ui.patch
Created attachment 22286 [details]
org.eclipse.wst.sse.ui.tests.patch
Created attachment 22287 [details]
org.eclipse.wst.xml.core.patch
Created attachment 22288 [details]
org.eclipse.wst.xml.ui.patch
Created attachment 22289 [details]
org.eclipse.wst.xml.ui.tests.patch
fixed so now when users select indent using spaces in the XX Source Formatting preference, spaces are used. This includes when you hit the tab key on its own, or if you hit tab key with multiple lines selected, shift right, shift left. add dependency on bug 82296 so that when that "spaces for tabs" function is finally pushed down to base, we can react to it. Fix details: (the following applies to JSP, CSS, HTML, XML) -Fixed AutoEdit so when tabs are pressed, and "indent using spaces" spaces are inserted instead -Fixed ViewerConfiguration by adding getIndentPrefixes so when proper indentation is retrieved by Shift Right/Shift Left operation -Fixed StructuredTextViewer so indentprefixes is properly set on viewer when shift right/shift left -Added testGetIndentPrefixes to TestViewerConfiguration Additional fixes included: -small performance fix on css, html, xml formatters to use StringBuffer instead of String when calculating indentation -make StructuredTextViewerConfigurationJSP use less internal classes by getting processors from StructuredTextViewerConfigurationHTML/XML -fixed bug 97729 Additional action needed: -delete org.eclipse.wst.sse.ui.internal.autoedit.BasicAutoEditStrategy if possible (i just deprecated it in my patch) Thanks, David. Thanks, Amy Committed to HEAD. Thanks Amy. Reopened this bug - with the I20050707 build, I still have "tab" inserted if I hit the "tab" key, instead of 2 spaces, as defined in preferences. This happens inside of scriplet code or inside of included javascript areas on any jsp we have. e.g. inside this code the spaces are inserted on "tab" key (this is ok): ------------ <%@ include file="/common/include/i18n/definitions.inc" %> <%@ taglib uri="/tags/xyz" prefix="fl" %> <jsp:useBean id="pageBean" scope="request" class="xyz.ResultPageBean"/> ------------ just few lines later, in the same jsp, tabs are inserted instead of spaces on "tab" key: ----------- <script type="text/javascript" language="JavaScript"> <!-- //--> </script> ----------- And 5 lines below we have scriplet code which also ignores "insert spaces for tabs" rule: <% FlightViewDTO flight = pageBean.getFlights().getSelectedFlight(); AirlineViewDTO marketingAirline = flight.getMarketingCarrier(); %> I'm sure that on all appropriated settings for all file types (html, css, jsp, js, xml, default) in whole Eclipse + WTP + Structured Editor + Java preferences I have *only* spaces for tabs defined. it is the autoeditstrategy that is handling when the tab key is pressed on its own. the problem is the java autoeditstrategy is used for jsp java regions and the default autoeditstrategy is used for non-html regions, like script and those autoeditstrategies do not have the spaces for tabs function built into them. a solution would be to separate the spaces for tab function out to its own autoeditstrategy and then add it as an autoeditstrategy for all regions (you can have multiple autoeditstrategies) Created attachment 24931 [details]
org.eclipse.jst.jsp.ui2.patch
Created attachment 24932 [details]
org.eclipse.wst.html.ui2.patch
Created attachment 24933 [details]
org.eclipse.wst.xml.ui2.patch
I've attached 3 new patches that should fix up the problem in comment #31. Solution is in comment #32. David, please apply new patches when you see fit. Since this is almost WTP's oldest bug (going from when originally opened) I think we should fix this for 0.7. Andrei, will you be in a position to quickly test this before our final RC2 build if I get this into a build on Tuesday or Wednesday? I can not promise it for this week, sorry. But the test case is very simply - just one plain jsp with some mixed jsp / java and javascript parts is enough to test it. Thanks Amy, patch applied to head. Will release for 7/20 I-build (for RC2). This bug was moved to 'closed' state, since it is so old and it is assumed really fixed and no longer useful or need further attention. Feel free to re-open, or open a new bug, if this semi-automatic processing was done in error. FYI: this is now supported for textual editors out of the box and there is API on the text viewer for this. See: ITextViewerExtension7.setTabsToSpacesConverter(IAutoEditStrategy) TabsToSpacesConverter AbstractTextEditor.installTabsToSpacesConverter() AbstractTextEditor.unnstallTabsToSpacesConverter() AbstractTextEditor.isTabsToSpacesConversionEnabled() |