Skip to content

Commit 33af27f

Browse files
fix selecting exact comment (codesandbox#3827)
* fix selecting exact comment * remove comment
1 parent b363336 commit 33af27f

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

packages/app/src/app/overmind/effects/vscode/ModelsHandler.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -759,18 +759,23 @@ export class ModelsHandler {
759759
const ids = lineCommentDecorations.map(
760760
commentDecoration => commentDecoration.commentId
761761
);
762-
const targetLineNumber = activeCommentDecoration
763-
? indexToLineAndColumn(
764-
model.getLinesContent() || [],
765-
activeCommentDecoration.range[1]
766-
).lineNumber
767-
: lineNumber;
762+
const commentRange = activeCommentDecoration
763+
? [
764+
indexToLineAndColumn(
765+
model.getLinesContent() || [],
766+
activeCommentDecoration.range[0]
767+
),
768+
indexToLineAndColumn(
769+
model.getLinesContent() || [],
770+
activeCommentDecoration.range[1]
771+
),
772+
]
773+
: null;
768774

769775
return aggr.concat(
770776
{
771777
range: new this.monaco.Range(lineNumber, 1, lineNumber, 1),
772778
options: {
773-
isWholeLine: true,
774779
// comment-id- class needs to be the LAST class!
775780
glyphMarginClassName: `editor-comments-glyph ${
776781
activeCommentDecoration ? 'editor-comments-active ' : ''
@@ -781,15 +786,24 @@ export class ModelsHandler {
781786
}editor-comments-ids-${ids.join('_')}`,
782787
},
783788
},
784-
{
785-
range: new this.monaco.Range(lineNumber, 1, targetLineNumber, 1),
786-
options: {
787-
isWholeLine: true,
788-
className: activeCommentDecoration
789-
? 'editor-comments-highlight'
790-
: undefined,
791-
},
792-
}
789+
commentRange
790+
? {
791+
range: new this.monaco.Range(
792+
commentRange[0].lineNumber,
793+
commentRange[0].column,
794+
commentRange[1].lineNumber,
795+
commentRange[1].column
796+
),
797+
options: {
798+
isWholeLine:
799+
commentRange[0].lineNumber === commentRange[1].lineNumber &&
800+
commentRange[0].column === commentRange[1].column,
801+
className: activeCommentDecoration
802+
? 'editor-comments-highlight'
803+
: undefined,
804+
},
805+
}
806+
: []
793807
);
794808
},
795809
initialDecorations

0 commit comments

Comments
 (0)