Bug 429433 - Preview popup shows code with indentation
Summary: Preview popup shows code with indentation
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Recommenders (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Andreas Sewe CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 436490
Blocks:
  Show dependency tree
 
Reported: 2014-03-03 03:39 EST by Johannes Dorn CLA
Modified: 2019-07-24 14:35 EDT (History)
2 users (show)

See Also:


Attachments
Whitespace in front -> bad looking indentation (42.05 KB, image/png)
2014-03-03 03:39 EST, Johannes Dorn CLA
no flags Details
No whitespace in front -> good looking preview (36.95 KB, image/png)
2014-03-03 03:39 EST, Johannes Dorn CLA
no flags Details
Somtimes wrong indentation (30.46 KB, image/png)
2014-05-21 10:05 EDT, Olav Lenz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Dorn CLA 2014-03-03 03:39:20 EST
Created attachment 240442 [details]
Whitespace in front -> bad looking indentation

The preview popup for the code shows the code with some bad looking indentation in some cases. 

The indentation in the preview popup seems to depend on the amount of whitespace in the currently selected line. If there is no whitespace at the start, the preview looks great. If there is some whitespace in front, the preview gets indented.
I have attached two screenshots that show the problem.

The indentation isn't really wrong though. The preview popup shows exactly what is inserted and the indentation has to be inserted for the snippet to be formatted correctly. The issue is just that the preview popup shouldn't display the indentation.
Comment 1 Johannes Dorn CLA 2014-03-03 03:39:59 EST
Created attachment 240443 [details]
No whitespace in front -> good looking preview
Comment 2 Andreas Sewe CLA 2014-05-08 09:33:04 EDT
Change in Gerrit: <https://git.eclipse.org/r/#/c/26216/>
Comment 3 Andreas Sewe CLA 2014-05-08 12:22:21 EDT
Fix merged.
Comment 4 Olav Lenz CLA 2014-05-21 10:05:58 EDT
Created attachment 243347 [details]
Somtimes wrong indentation
Comment 5 Olav Lenz CLA 2014-05-21 10:06:24 EDT
The fix seems not to work in all cases.

E.g. the snippet GridLayout has a wrong indentation(see attachment)
Comment 6 Andreas Sewe CLA 2014-05-21 10:08:18 EDT
For the record, the GridLayout template is correctly indented by Content Assist so apparently we don't mimic its behavior completely yet.
Comment 7 Andreas Sewe CLA 2014-06-03 12:50:08 EDT
(In reply to Andreas Sewe from comment #6)
> For the record, the GridLayout template is correctly indented by Content
> Assist so apparently we don't mimic its behavior completely yet.

The problem is "caused" by the comment (name + description) we add to the beginning of the snippet's preview. If you add the same leading comment to a JDT template, the Template Proposals Content Assist also indents incorrectly in its preview popup (now Bug 436490).
Comment 8 Andreas Sewe CLA 2014-06-04 05:16:49 EDT
Fix in Gerrit: <https://git.eclipse.org/r/27909>. (Fixes only our indentation logic, not JDT's.)
Comment 9 Johannes Dorn CLA 2014-06-04 10:30:19 EDT
The fix is merged. This does NOT fix JDT Bug 436490 but works around that issue by not indenting our snippet description comment which is only shown in the preview.
Comment 10 Marcel Bruch CLA 2014-06-19 06:34:07 EDT
Closing for 2.1