Bug 160278 - Tab Conversion in Assembly editor
Summary: Tab Conversion in Assembly editor
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 4.0 M6   Edit
Assignee: Anton Leherbauer CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-10-10 05:22 EDT by Robert Norton CLA
Modified: 2009-01-09 15:03 EST (History)
1 user (show)

See Also:


Attachments
Proposed patch (27.74 KB, patch)
2006-10-10 05:25 EDT, Robert Norton CLA
no flags Details | Diff
Second patch attempt. (18.78 KB, patch)
2006-10-15 10:58 EDT, Robert Norton CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Norton CLA 2006-10-10 05:22:35 EDT
The C editor already has the ability to convert tabs to spaces. This is ofter useful in meeting code style guidelines. Unfortunately the assembly editor lacks this ability. I have created a patch which refactors the existing functionality to make it available to both CEditor and AsmEditor.
Comment 1 Robert Norton CLA 2006-10-10 05:25:01 EDT
Created attachment 51666 [details]
Proposed patch

This patch is made against our cvs tree which has been selectively patched from cdt head and also hand edited. Hence I'm not sure how it compares with the current HEAD and whether it can be applied. If this is a problem let me know and I will check out HEAD and diff against it...
Comment 2 Anton Leherbauer CLA 2006-10-10 07:59:14 EDT
Please provide a patch against HEAD, because it has changed a lot since.
Creating a common editor base class for language independent features makes sense. I noticed that your patch also adds bracket highlighting to the assembly editor. Is this intended?

Comment 3 Robert Norton CLA 2006-10-10 08:11:12 EDT
(In reply to comment #2)
> Please provide a patch against HEAD, because it has changed a lot since.

OK. I'll get on to this.

> Creating a common editor base class for language independent features makes
> sense. 

Yes -- it would be even more ideal if these were incorporated into the platforms TextEditor or something...

> I noticed that your patch also adds bracket highlighting to the assembly
> editor. Is this intended?

In fact it was unintended -- I did the refactoring in rather a hurry and this stuff must have been pulled in by accident. It does make some sense to have it there though... Also I've been testing the patch over the last week or two and haven't noticed any other unintended side effects.

Comment 4 Robert Norton CLA 2006-10-10 08:58:37 EDT
No kidding when you say there's been a lot of changes!

I'm afraid I don't have time to do the merge right now. Probably the easiest option would be to perform the refactoring again. IIRC i just used 'Extract Superclass' to extract all the relevant fields/methods into a class called AbstractCDTEditor then made this the superclass for AsmTextEditor. There was also some fiddling around since CSourceViewer (which it appears now contains the TabConverter class) needed to be treated in a similar manner.
Comment 5 Robert Norton CLA 2006-10-15 10:58:27 EDT
Created attachment 52000 [details]
Second patch attempt.

This patch should apply against head. I've tested it briefly and it appeared to work as intented. You may have to adjust code-style settings to see the behaviour. This patch also opens the door to making more CDT specific editor functionality to the assembly editor (and any other editors kicking around).
Comment 6 Anton Leherbauer CLA 2006-10-17 10:23:43 EDT
Thanks for the update. Some issues remain:
- Tab conversion should be enabled when the editor is opened and not only when the settings are changed (@see CEDitor#createPartControl()). 
- The abstract editor should also update the textwidget's tab width upon preference changes (@see CEditor#handlePreferenceStoreChanged()).
- The source viewer configuration should also be refactored to a common abstract class - to share the same tab-width and indent prefixes
- Please add a proper copyright comment and javadoc to new classes.
Comment 7 Anton Leherbauer CLA 2007-03-22 06:56:06 EDT
Seems like the platform has added support for that in the general text editor (bug 82296). This way, the assembly editor would get that for free, I think.
Comment 8 Robert Norton CLA 2007-03-22 07:17:37 EDT
Great! In order to take advantage of this the AsmSourceViewerConfiguration must make sure to pass its preference store to the parent in the constructor. This ensures that the AsmTextEditor inherits all the settings from the platform text editor e.g. tab width, tab conversion...
Comment 9 Anton Leherbauer CLA 2007-03-22 08:08:12 EDT
Thanks for the hint. I'll look into it.
Comment 10 Anton Leherbauer CLA 2007-03-23 10:00:25 EDT
Fixed. The Assembly Editor now supports the platform provided spaces for tabs feature.