Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Cut selection if exists, otherwise the paragraph

AuthorDaveJarvis <email>
Date2020-07-10 19:17:55 GMT-0700
Commitc6db50e1b55e53829a3401e924e060971f1f9ff5
Parent8a9eead
Delta13 lines added, 3 lines removed, 10-line increase
src/main/java/com/scrivenvar/editors/EditorPane.java
}
+ /**
+ * Cuts the actively selected text; if no text is selected, this will cut
+ * the entire paragraph.
+ */
public void cut() {
- getEditor().selectParagraph();
- getEditor().cut();
+ final var editor = getEditor();
+ final var selected = editor.getSelectedText();
+
+ if( selected == null || selected.isEmpty() ) {
+ editor.selectParagraph();
+ }
+
+ editor.cut();
}
src/main/java/com/scrivenvar/editors/VariableNameInjector.java
/**
- * Inserts the variable
+ * Inserts the currently selected variable from the {@link DefinitionPane}.
*/
public void injectSelectedItem() {