@@ -29,22 +29,23 @@ export default function setupEventListener(
29
29
30
30
if ( activeEditor && event . document === activeEditor . document ) {
31
31
/**
32
- * redo and undo
32
+ * redo, undo and line change
33
33
*/
34
- if ( event . reason ) {
34
+ diffLine = activeEditor . document . lineCount - fileLineCount ;
35
+ fileLineCount = activeEditor . document . lineCount ;
36
+ if ( event . reason || diffLine !== 0 ) {
35
37
decorationManager . triggerUpdateDecorations ( true ) ;
36
38
} 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 ;
44
45
45
46
decorationManager . setActiveEditor ( activeEditor ) ;
46
47
decorationManager . triggerUpdateDecorations (
47
- diffLine === 0 ,
48
+ true ,
48
49
true ,
49
50
diffLine ,
50
51
startLine ,
@@ -82,11 +83,15 @@ export default function setupEventListener(
82
83
const startLinePos = document . lineAt ( startLine ) ;
83
84
84
85
const isStartLineEmpty = startLinePos . isEmptyOrWhitespace ;
86
+ const isSecondLineEmpty = document . lineAt (
87
+ startLine + 1
88
+ ) . isEmptyOrWhitespace ;
85
89
const startLineLastPos = new vscode . Position (
86
90
startLine ,
87
91
Math . max ( startLinePos . text . length , 0 )
88
92
) ;
89
- const isStartLineLastPos = startLineLastPos . isEqual ( change . range . start ) ;
93
+ const startRange = change . range . start ;
94
+ const isStartLineLastPos = startLineLastPos . isEqual ( startRange ) ;
90
95
91
96
/**
92
97
* paste multiple lines
@@ -109,7 +114,7 @@ export default function setupEventListener(
109
114
/**
110
115
* enter
111
116
*/
112
- if ( ! isStartLineEmpty && diffLine === 1 && startLine === endLine ) {
117
+ if ( ! isStartLineEmpty && isSecondLineEmpty && diffLine === 1 ) {
113
118
startLine += 1 ;
114
119
endLine += 1 ;
115
120
}
0 commit comments