This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 91341 - "reformat code" action does not work
Summary: "reformat code" action does not work
Status: VERIFIED FIXED
Alias: None
Product: ruby
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Torbjorn Norbye
URL:
Keywords:
: 95883 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-12-20 14:28 UTC by Tomas Danek
Modified: 2007-07-03 14:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Danek 2006-12-20 14:28:26 UTC
#192:

As I am used from java editor, i often press CTRL+SHIFT+F in order to
potentially  reformat code, but in ruby editor, it simply deleted all my
indention.. If you don't plan to spend time with implementation of code
formating in ruby in near future, please, disable the reformat action for now,
thanks.
Comment 1 Torbjorn Norbye 2006-12-22 16:58:12 UTC
Ugh. Sorry about that. Hopefully Undo got your indentation back?

The reason it is that way right now is that the smart-indent feature (indenting
when you hit Return) relies on the same hooks as reformat. I had hoped that
Reformat would simply have the same effect as doing a reindent on every line;
indeed that -is- what is happening, but the context passed in differs which ends
up confusing the reindentation code (it doesn't see the previous line's
indentation because it hasn't been reflected in the Document yet. I need to redo
this in terms of a token stream rather than raw Document computations, which
I've planned to do shortly along with similar changes to the pair-matching of
braces, quotes, etc.)
Comment 2 Torbjorn Norbye 2007-02-16 20:49:30 UTC
This is now integrated.

Since the APIs for the indentation engines are not lexer based yet, I
implemented this (temporarily) by iterating over the document, using the lexer
token hierarchy to look for tokens related to indentation, and then building up
a reformatted string builder on the fly, which I finally use to replace the
document contents.

The reformatting seems to work well; I reformatted some large Ruby library files
(imap.rb, irb.rb) with expected results. (There is a problem with heredocs with
embedded ruby which I am fixing separately.)

Anyway, both smart indentation and full source reformatting should be ok now.
Comment 3 Tomas Danek 2007-02-19 10:47:22 UTC
*** Issue 95883 has been marked as a duplicate of this issue. ***
Comment 4 Tomas Danek 2007-02-22 17:29:49 UTC
verified.
Comment 5 Jiri Kovalsky 2007-07-03 14:01:58 UTC
Reassigning this issue to newly created 'ruby' component.
Comment 6 Jiri Kovalsky 2007-07-03 14:44:23 UTC
Changing target milestone of all resolved Ruby issues from TBD to 6.0 Beta 1 build.