Skip to content
Permalink
Browse files

Merge pull request #6714 from vivekworks/devel

#6630 Enquoting selected text deletes it instead
  • Loading branch information...
serge-rider committed Sep 11, 2019
2 parents 72f72de + 99b426c commit 18520a51a493a4c2c5c5f4802586f2832bbc55e7
@@ -22,6 +22,7 @@
import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.VerifyEvent;
@@ -205,7 +206,7 @@ public void verifyKey(VerifyEvent event)
final char character = event.character;
final char closingCharacter = getPeerCharacter(character);

document.replace(offset, length, String.valueOf(character) + closingCharacter);
document.replace(offset, length, String.valueOf(character)+ getSelection() + closingCharacter);

SymbolLevel level = new SymbolLevel();
bracketLevelStack.add(level);
@@ -240,7 +241,7 @@ public void verifyKey(VerifyEvent event)

IRegion newSelection = level.uI.getSelectedRegion();
sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());

event.doit = false;

}
@@ -454,5 +455,17 @@ public EditorLinkedModeUI(LinkedModeModel model, ITextViewer viewer) {
setPositionListener(new EditorHistoryUpdater());
}
}

private String getSelection() {
ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider == null) {
return null;
}
ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
if(selection == null) {
return null;
}
return selection.getText();
}

}

0 comments on commit 18520a5

Please sign in to comment.
You can’t perform that action at this time.