Skip to content

Commit f4ec6de

Browse files
committed
improve readability
1 parent c8b0810 commit f4ec6de

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

docs/translate/translate.gs

+3-5
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ function showSidebar() {
7373
*/
7474
function getSelectedText() {
7575
var selection = DocumentApp.getActiveDocument().getSelection();
76+
var text = [];
7677
if (selection) {
77-
var text = [];
7878
var elements = selection.getSelectedElements();
7979
for (var i = 0; i < elements.length; ++i) {
8080
if (elements[i].isPartial()) {
@@ -97,11 +97,9 @@ function getSelectedText() {
9797
}
9898
}
9999
}
100-
101-
if (text.length) return text;
102100
}
103-
104-
throw new Error('Please select some text.');
101+
if (!text.length) throw new Error('Please select some text.');
102+
return text;
105103
}
106104

107105
/**

0 commit comments

Comments
 (0)