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 - TypedTextinterceptor needs method to get Replaced Text.
Summary: TypedTextinterceptor needs method to get Replaced Text.
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal (vote)
Assignee: Milutin Kristofic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-24 15:00 UTC by Milutin Kristofic
Modified: 2013-01-31 03:13 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch for getReplacedText Api (7.14 KB, patch)
2013-01-24 15:08 UTC, Milutin Kristofic
Details | Diff
patch for getReplacedText Api (7.16 KB, patch)
2013-01-24 15:11 UTC, Milutin Kristofic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.