Skip to content

Commit a149662

Browse files
committed
Use toRange2 helper
1 parent 05ec979 commit a149662

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/omnisharp/typeConversion.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,10 @@ export function toVSCodePosition(point: protocol.V2.Point): vscode.Position {
6363
}
6464

6565
export function toVSCodeTextEdit(textChange: protocol.LinePositionSpanTextChange): vscode.TextEdit {
66-
return new vscode.TextEdit(toVSCodeRange(textChange), textChange.NewText);
67-
68-
function toVSCodeRange(textChange: protocol.LinePositionSpanTextChange): vscode.Range {
69-
const newStart = new vscode.Position(textChange.StartLine, textChange.StartColumn);
70-
const newEnd = new vscode.Position(textChange.EndLine, textChange.EndColumn);
71-
return new vscode.Range(newStart, newEnd);
72-
}
66+
return new vscode.TextEdit(toRange2(textChange), textChange.NewText);
7367
}
7468

75-
export function createRequest<T extends protocol.Request>(document: vscode.TextDocument, where: vscode.Position | vscode.Range, includeBuffer: boolean = false): T {
76-
77-
let Line: number, Column: number;
78-
79-
if (where instanceof vscode.Position) {
80-
Line = where.line;
81-
Column = where.character;
82-
} else if (where instanceof vscode.Range) {
83-
Line = where.start.line;
84-
Column = where.start.character;
85-
}
86-
69+
export function createRequest<T extends protocol.Request>(document: vscode.TextDocument, where: vscode.Position, includeBuffer: boolean = false): T {
8770
// for metadata sources, we need to remove the [metadata] from the filename, and prepend the $metadata$ authority
8871
// this is expected by the Omnisharp server to support metadata-to-metadata navigation
8972
const fileName = document.uri.scheme === "omnisharp-metadata" ?
@@ -93,8 +76,8 @@ export function createRequest<T extends protocol.Request>(document: vscode.TextD
9376
const request: protocol.Request = {
9477
FileName: fileName,
9578
Buffer: includeBuffer ? document.getText() : undefined,
96-
Line: Line,
97-
Column: Column,
79+
Line: where.line,
80+
Column: where.character,
9881
};
9982

10083
return <T>request;

0 commit comments

Comments
 (0)