Skip to content

Commit

Permalink
refactor: change variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
seonim-ryu committed Jul 14, 2020
1 parent 69d92e7 commit 7057fba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/editor/src/js/markdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,23 +391,23 @@ class MarkdownEditor extends CodeMirrorExt {
}

_changeTextToTaskMarker() {
const { line: curLine, ch: curCh } = this.cm.getCursor();
const mdCh = this.cm.getLine(curLine).length === curCh ? curCh : curCh + 1;
const mdNode = this.toastMark.findNodeAtPosition([curLine + 1, mdCh]);
const { line, ch } = this.cm.getCursor();
const mdCh = this.cm.getLine(line).length === ch ? ch : ch + 1;
const mdNode = this.toastMark.findNodeAtPosition([line + 1, mdCh]);
const paraNode = findClosestNode(
mdNode,
node => node.type === 'paragraph' && node.parent && node.parent.type === 'item'
);

if (paraNode && paraNode.firstChild) {
const { literal, sourcepos } = paraNode.firstChild;
const [[line, ch]] = sourcepos;
const [[startLine, startCh]] = sourcepos;
const matched = literal.match(TASK_MARKER_RX);

if (matched) {
const [, startSpaces, stateChar, lastSpaces] = matched;
const spaces = startSpaces.length + lastSpaces.length;
const startPos = { line: line - 1, ch };
const startPos = { line: startLine - 1, ch: startCh };

if (stateChar) {
this.cm.replaceRange(stateChar, startPos, addChPos(startPos, spaces ? spaces + 1 : 0));
Expand Down

0 comments on commit 7057fba

Please sign in to comment.