Skip to content

Commit

Permalink
trun enable function call from registerCodeMriiro from `this.app.wo…
Browse files Browse the repository at this point in the history
…rksapce.iteratorCodeMirror`
  • Loading branch information
lijyze committed Apr 18, 2022
1 parent 657371d commit ec88984
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions ScrollOffsetCM6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function generateScrollOffsetCM6Plugin(calcRequiredOffset: (container: HTMLEleme
if (cursor) {
if (this.switch) {
/**
* Can't use `lineHeight` because multiple line paragraph
* Can't use `lineHeight` because of multiple line paragraph
* But cursorHeight is less then lineHeight about 5px
* So add this 5px;
*/
Expand All @@ -49,7 +49,6 @@ function generateScrollOffsetCM6Plugin(calcRequiredOffset: (container: HTMLEleme
}
})
}

}
},
{
Expand Down
3 changes: 2 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class ScrollOffset extends Plugin {
const container = cm.getWrapperElement();
const requiredOffset = this.calcRequiredOffset(container, cursorHeight);

// First argument `null` means the cursor
cm.scrollIntoView(null, requiredOffset)
}

Expand All @@ -64,7 +65,7 @@ export default class ScrollOffset extends Plugin {
}

disableScrollOffset = () => {
this.registerCodeMirror(cm => {
this.app.workspace.iterateCodeMirrors(cm => {
cm.off('mousedown', this.mouseDownHandler)
cm.off('cursorActivity', this.cursorActiveHandler);
})
Expand Down

0 comments on commit ec88984

Please sign in to comment.