Bug 105179 - [linked mode] LinkedModeUi exiting too early
Summary: [linked mode] LinkedModeUi exiting too early
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2005-07-26 12:26 EDT by Keith McQueen CLA
Modified: 2019-09-06 16:11 EDT (History)
2 users (show)

See Also:


Attachments
Sample plugin to reproduce the problem (20.31 KB, application/zip)
2005-07-26 12:28 EDT, Keith McQueen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Keith McQueen CLA 2005-07-26 12:26:49 EDT
I have a custom text editor that enters LinkedModeUI for existing text when the
<TAB> key is pressed.  It seems to work pretty well.  I can tab through the
"fields" of my text, but as soon as I type a character, the LinkedModeUI seems
to exit (all the "boxes" or "fields" disappear and I am left with my plain old
text again).  When invoking a template, the LinkedModeUI doesn't exit until the
user presses <ENTER> or <ESC>.  I have compared the code in
TemplateProposal.apply() and it seems very much like mine (in fact I used it as
a model for mine).  The only difference I can see is that there is the use of
ensurePositionCategoryInstalled() which uses the InclusivePositionUpdater (which
the javadoc instructs the mortal programmer not to use because it is only public
for testing purposes). It also adds a position to the document for each
potential value for the  template variable.

I have built a sample which will demonstrate the problem and I will attach it to
this bug.  Thanks for the help.
Comment 1 Keith McQueen CLA 2005-07-26 12:28:01 EDT
Created attachment 25305 [details]
Sample plugin to reproduce the problem

This .zip file contains a deployable plugin (with source) that should
demonstrate the problem.
Comment 2 Keith McQueen CLA 2005-07-26 12:32:13 EDT
The attached plugin was built using the wizard and selecting the "Plug-in with
an Editor" template.  It contains a simple XML editor (generated by the wizard)
that I modified to enter LinkedModeUI when the user presses the <TAB> key.  This
is all done in the createPartControl() method.  I simply create positions for
the LinkedModeUI for every 5 characters.  You should be able to use any .xml
file with this editor.  Just press <TAB> to enter the LinkedModeUI and then you
can tab through the positions.  <ESC> and <ENTER> work as expected, but as soon
as you type a character in any of the positions, LinkedModeUI exits.  Again,
thanks for the help and let me know what more information you need.

Keith
Comment 3 Keith McQueen CLA 2005-07-29 12:52:35 EDT
I am upgrading the priority/severity on this bug, because I have not seen any
action on it whatsoever.  Let me know if there is anything you need from me.  I
would love to get this resolved, even if it is something silly I'm doing (or not
doing, as the case may be).

Thanks,
Keith
Comment 4 Dani Megert CLA 2005-08-04 04:54:47 EDT
Tom, please comment.
Comment 5 Tom Hofmann CLA 2005-08-04 07:08:40 EDT
Oh, I see what you mean now, thanks for the example plug-in. Note that modifying
a linked position works when the change is strictly contained within a single
position.

When adapting linked positions to document changes, currently any change
overlapping with a linked position or *occurring at its borders* is considered
to modify the position. See InclusivePositionUpdater. 

This is so in order to include characters typed in at the begin and end offsets
of a linked position.

In your example, typing a character to replace the contents of one linked
position results in three positions being updated: the selected one, and the
positions to its left and right. Note that ajacent linked positions do not
behave well when a change occurs on their common offset. It is not clear to
which position a character belongs that is inserted at the join. Therefore,
adjacent linked positions are not supported.

We could, however, be a little smarter: if a document change has a length
greater than zero and does not overlap with the position (i.e. replaces a
document range adjacent to a linked position), we could savely consider the
change to not touch the position.

This would help you in the described scenario of comment 2. Other scenarios
would still not work, though: if you tab to a linked position and press Delete,
you end up with a zero-length linked position between two other positions.
Inserting characters in that situation would be ambiguous.

Are adjacent positions absolutely required for what you are trying to do? What
are the semantics that you would suggest for dealing with adjacent positions?

Closing as won't fix as there is not much we can do as long as the semantics of
adjacent positions are unclear. Please feel free to reopen to continue the
discussion.
Comment 6 Keith McQueen CLA 2005-08-04 12:49:55 EDT
Thanks for the reply.  You have cleared up for me a little of the problem.  Let
me continue in more detail with my issue.  Our text editor basically deals with
editing a text file composed of records.  Each line is a record with fields
defined at certain offsets and lengths.  The issue you mentioned where if the
user were to delete all text within a linked position and then start entering
text again is a problem because there were the three adjacent positions, the one
in the middle now has 0 length, so when the user starts entering text again,
each of the three linked positions is confused as to whose characters those are.  

Really, in a fixed width record, the problem is much simpler.  Each linked
position is defined to occupy a fixed range (unless it is the last in the line,
and then it may shrink as the line shrinks).  Therefore, the linked positions
are only allowed to accept characters within their defined range.  If I type
some characters at some position in the line, they belong only to the linked
position that owns that position, if I keep typing and run into the range of
another linked position, then those characters belong to the second linked
position.  

Does this make any sense?  We are simply dealing with fixed-width semantics
here, not variable width.
Comment 7 Tom Hofmann CLA 2005-08-15 05:46:40 EDT
I don't think that the described scenario will work well when implemented via
linked mode. The entire point of linked mode is that its positions (offsets &
lengths) are dynamically updated as you type. In contrast, you want the
positions to have a constant length.

This is not something we are planning to support - I think it would be better to
implement your own solution, possibly by copying and modifying the code of
linked mode.

Closing as works for me as linked mode works as expected (no bug).
Comment 8 Keith McQueen CLA 2005-08-15 14:27:33 EDT
I think copy+paste coding is about the worst approach to solving problems there
is , especially when "reusable" object exist.  The problem with the current
solution on the linked mode is that the classes are not terribly "reusable."  I
could copy the existing LinkedModeModel class and replace instances of
InclusivePositionUpdater with my own version but that sure seems a waste of
duplicated code.  I could subclass the LinkedModeModel and just override the
methods where the InclusivePositionUpdater is used, replacing it with my own
position updater again, but then I run the risk of "not keeping up" with changes
that are made to the base class.  

It seems to me that the best solution would be to allow the user to (get this)
"plug in" their own position updater, or whatever they like.  The comment that
you will not support unintended functionality is like saying that Eclipse was
intended as a Java IDE and therfore you won't support any functionality that has
nothing to do with Java.  I have encountered a number of key locations where the
"intended" functionality is so locked down that one has to completely reinvent
the wheel.  This seems contrary to the goals of Eclipse.  Open up and let the
users/develpers decide how they want things implemented.  They can keep the
wheel as it is or they can provide their own customizations, or entire
reimplementations.
Comment 9 Tom Hofmann CLA 2005-08-16 03:28:44 EDT
No bug, but an enhancement request then - changing severity accordingly.

There are currently no plans to work on this, but a high quality patch (and
tests) would be welcome.
Comment 10 Dani Megert CLA 2005-08-16 10:59:02 EDT
.
Comment 11 Dani Megert CLA 2005-08-18 12:02:24 EDT
I agree that copy/paste code is bad but as Tom said, we currently don't plan to
work on this unless we receive a good patch.
Comment 12 Dani Megert CLA 2007-06-22 09:59:25 EDT
Get rid of deprecated state.
Comment 13 Eclipse Webmaster CLA 2019-09-06 16:11:52 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.