@@ -29,22 +29,23 @@ export default function setupEventListener(
2929
3030 if ( activeEditor && event . document === activeEditor . document ) {
3131 /**
32- * redo and undo
32+ * redo, undo and line change
3333 */
34- if ( event . reason ) {
34+ diffLine = activeEditor . document . lineCount - fileLineCount ;
35+ fileLineCount = activeEditor . document . lineCount ;
36+ if ( event . reason || diffLine !== 0 ) {
3537 decorationManager . triggerUpdateDecorations ( true ) ;
3638 } else {
37- diffLine = activeEditor . document . lineCount - fileLineCount ;
38- fileLineCount = activeEditor . document . lineCount ;
39-
40- const [ startLine , endLine ] = getStartEndLine (
41- event . document ,
42- event . contentChanges [ 0 ]
43- ) ;
39+ // const [startLine, endLine] = getStartEndLine(
40+ // event.document,
41+ // event.contentChanges[0]
42+ // );
43+ const startLine = event . contentChanges [ 0 ] . range . start . line ;
44+ const endLine = event . contentChanges [ 0 ] . range . end . line ;
4445
4546 decorationManager . setActiveEditor ( activeEditor ) ;
4647 decorationManager . triggerUpdateDecorations (
47- diffLine === 0 ,
48+ true ,
4849 true ,
4950 diffLine ,
5051 startLine ,
@@ -82,11 +83,15 @@ export default function setupEventListener(
8283 const startLinePos = document . lineAt ( startLine ) ;
8384
8485 const isStartLineEmpty = startLinePos . isEmptyOrWhitespace ;
86+ const isSecondLineEmpty = document . lineAt (
87+ startLine + 1
88+ ) . isEmptyOrWhitespace ;
8589 const startLineLastPos = new vscode . Position (
8690 startLine ,
8791 Math . max ( startLinePos . text . length , 0 )
8892 ) ;
89- const isStartLineLastPos = startLineLastPos . isEqual ( change . range . start ) ;
93+ const startRange = change . range . start ;
94+ const isStartLineLastPos = startLineLastPos . isEqual ( startRange ) ;
9095
9196 /**
9297 * paste multiple lines
@@ -109,7 +114,7 @@ export default function setupEventListener(
109114 /**
110115 * enter
111116 */
112- if ( ! isStartLineEmpty && diffLine === 1 && startLine === endLine ) {
117+ if ( ! isStartLineEmpty && isSecondLineEmpty && diffLine === 1 ) {
113118 startLine += 1 ;
114119 endLine += 1 ;
115120 }
0 commit comments