Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions spx-gui/src/components/editor/code-editor/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export type Position = {
}

export type Range = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style improvement: Use consistent parenthetical notation for better readability and to match common documentation patterns.

Suggested change
export type Range = {
export type Range = {
/** The range's start position (inclusive) */
start: Position
/** The range's end position (exclusive) */
end: Position
}

/** The range's start position, inclusive */
start: Position
/** The range's end position, exclusive */
end: Position
}

Expand Down Expand Up @@ -449,7 +451,7 @@ export function isSelectionEmpty(selection: Selection | null) {
export function containsPosition(range: Range, position: Position) {
if (position.line < range.start.line || position.line > range.end.line) return false
if (position.line === range.start.line && position.column < range.start.column) return false
if (position.line === range.end.line && position.column > range.end.column) return false
if (position.line === range.end.line && position.column >= range.end.column) return false
Copy link
Collaborator Author

@nighca nighca Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们明确 range end 是 exclusive 的,与 range end 相同的 position 视作不被 range 包含

对应地,一个 identifier,其 range end position 所触发的 hover,我们处理为“不触发该 identifer 对应的 hover 内容”;这里的调整使得 code-editor-ui 侧的行为(见 code-editor/ui/hover/index.ts)遵循该设定

不过目前 LS 侧行为跟该设定不一致

return true
}

Expand Down Expand Up @@ -823,7 +825,10 @@ export function rangeEq(a: Range | null, b: Range | null) {
}

export function rangeContains(a: Range, b: Range) {
return containsPosition(a, b.start) && containsPosition(a, b.end)
return (
(positionEq(a.start, b.start) || positionAfter(b.start, a.start)) &&
(positionEq(a.end, b.end) || positionAfter(a.end, b.end))
)
}

const textDocumentURIPrefix = 'file:///'
Expand Down
Loading