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 225293

Summary: TypedTextinterceptor needs method to get Replaced Text.
Product: editor Reporter: Milutin Kristofic <mkristofic>
Component: -- Other --Assignee: Milutin Kristofic <mkristofic>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: patch for getReplacedText Api
patch for getReplacedText Api

Description Milutin Kristofic 2013-01-24 15:00:26 UTC
In some languages (e.g. HTML, PHP) you can select text and press quote (', ") and  selected text is given to quotes.

This is not possible implemented with typing hooks implementation. We need new API to enable this.
Comment 1 Milutin Kristofic 2013-01-24 15:08:49 UTC
Created attachment 130592 [details]
patch for getReplacedText Api

I propose new method getReplacedText. I changed implementation to obtain replacedText during creation of interceptor.

Example for use, this would enable in java selecting text and pressing quote to give text in quotes. 
--- a/java.editor/src/org/netbeans/modules/editor/java/TypingCompletion.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/TypingCompletion.java
@@ -259,7 +259,11 @@
         }
 
         if ((completablePosition && !insideString) || eol) {
-            context.setText(context.getText() + context.getText(), 1);
+            if (context.getReplacedText() != null) {
+                context.setText(context.getText() + context.getReplacedText() + context.getText(), context.getReplacedText().length() + 1);
+            } else {
+                context.setText(context.getText() + context.getText(), 1);
+            }
         }
         return -1;
     }
Comment 2 Milutin Kristofic 2013-01-24 15:11:00 UTC
Created attachment 130593 [details]
patch for getReplacedText Api

new patch - fixed changes.xml
Comment 3 Milutin Kristofic 2013-01-30 10:34:46 UTC
http://hg.netbeans.org/jet-main/rev/5405efa8ac8a
Comment 4 Quality Engineering 2013-01-31 03:13:57 UTC
Integrated into 'main-golden', will be available in build *201301310001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5405efa8ac8a
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #225293 - TypedTextinterceptor needs method to get Replaced Text.