void duplicateLine() {
/*
* Guard for readonly files because Buffer.insert()
* ignores the flag
*
*/
if (buffer.isReadOnly()) {
Macros.error(view, "This file is read only.");
return;
}
line = textArea.getCaretLine();
offset = textArea.getLineEndOffset(line);
// handle last line differently
if (line == textArea.getLineCount() - 1) {
text = "\n" + textArea.getLineText(line);
--offset;
} else {
text = textArea.getLineText(line) + "\n";
}
buffer.insert(offset, text);
textArea.goToNextLine(false);
}
duplicateLine();