errael opened a new pull request, #4249:
URL: https://github.com/apache/netbeans/pull/4249

   This PR adds an event, `PROP_RELOADED`, _after_ a document is reloaded due 
to an external change.
   
   This change is about handling fixup after a document is reloaded. Currently, 
`openide.text` adjusts any document positions such that after the reload the 
`PositionRef`s have the same line number and column offset. However, the 
**caret positions** in any editors are set to have the same offset as before; 
and so the caret often seems to jump around after the reload. Maintaining 
line/col seems preferable. This was discussed in the dev mailing list thread:
   ```
       Detecting file changed externally, 2022, Jun 7
       https://lists.apache.org/thread/tb1mkx1koctt74y48gbyqhqsbtrq56ys
   ```
   
   Changing `DocumentOpenClose` handling of caret has at least two issue.
   1. It's an incompatible change
   2. More importantly, `EditorLib2` introduced multiple carets, and 
`DocumentOpenClose` is pure swing for caret handling. A dependency on on 
`org.netbeans.api.editor.caret` seems unacceptable.
   
   With the `PROP_RELOADED` event things can be handled as needed where needed; 
an editor kit might use this.
   
   For example, using events, carets line/col can be preserved after reload 
like this:
   1. `FileChangeListener.fileChanged(FileEvent)`
   Save `PositionRef` for each caret
   2. `PROP_RELOADED` event
   Restore caret position from `PositionRef` saved in 1.
   
   Note that there is usually many saves in a row from 1). Restore is only done 
rarely with 2).
   
   The `PROP_RELOADED` event is fired on the EDT. This is probably the right 
choice, but in this case it is required to insure that the event is after 
`DocumentOpenClose` adjusts the carets and after it gets the 
`CloneableEditorSupport` ready for prime time.
   
   Documentation after there's agreement.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to