Skip to content

Commit

Permalink
fix: fixed "Mark decorations may not be empty" error (#2867)
Browse files Browse the repository at this point in the history
* fix: fixed "Mark decorations may not be empty"  error
  • Loading branch information
imolorhe committed Nov 7, 2022
1 parent 7da648b commit 9fd1283
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-moose-sin.md
@@ -0,0 +1,5 @@
---
"cm6-graphql": patch
---

fix: fixed "Mark decorations may not be empty" error
23 changes: 15 additions & 8 deletions packages/cm6-graphql/src/lint.ts
Expand Up @@ -18,15 +18,22 @@ export const lint = linter(view => {
return null;
}

const calculatedFrom = posToOffset(
view.state.doc,
new Position(item.range.start.line, item.range.start.character),
);
const from = Math.max(0, Math.min(calculatedFrom, view.state.doc.length));
const calculatedRo = posToOffset(
view.state.doc,
new Position(item.range.end.line, item.range.end.character - 1),
);
const to = Math.min(
Math.max(from + 1, calculatedRo),
view.state.doc.length,
);
return {
from: posToOffset(
view.state.doc,
new Position(item.range.start.line, item.range.start.character),
),
to: posToOffset(
view.state.doc,
new Position(item.range.end.line, item.range.end.character - 1),
),
from,
to: from !== to ? to : to + 1,
severity: SEVERITY[item.severity - 1],
// source: item.source, // TODO:
message: item.message,
Expand Down

0 comments on commit 9fd1283

Please sign in to comment.