Skip to content

Commit 9bb23f2

Browse files
committed
Merge branch 'main' of github.com:quarto-dev/quarto-cli into main
2 parents 035cb09 + b16b36a commit 9bb23f2

File tree

16 files changed

+161
-83
lines changed

16 files changed

+161
-83
lines changed

src/core/handlers/dot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
isRevealjsOutput,
1515
} from "../../config/format.ts";
1616
import { QuartoMdCell } from "../lib/break-quarto-md.ts";
17-
import { mappedConcat, mappedIndexToRowCol } from "../lib/mapped-text.ts";
17+
import { mappedConcat, mappedIndexToLineCol } from "../lib/mapped-text.ts";
1818

1919
import { lineOffsets } from "../lib/text.ts";
2020
import {
@@ -79,7 +79,7 @@ const dotHandler: LanguageHandler = {
7979
);
8080
if (m) {
8181
const number = Number(m[2]) - 1;
82-
const locF = mappedIndexToRowCol(cellContent);
82+
const locF = mappedIndexToLineCol(cellContent);
8383
const offsets = Array.from(lineOffsets(cellContent.value));
8484
const offset = offsets[number];
8585
const mapResult = cellContent.map(offset, true);

src/core/lib/mapped-text.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { glb } from "./binary-search.ts";
99
import { rangedLines } from "./ranged-text.ts";
1010

1111
import {
12-
indexToRowCol as unmappedIndexToRowCol,
12+
indexToLineCol as unmappedIndexToLineCol,
1313
lineBreakPositions,
1414
matchAll,
1515
} from "./text.ts";
@@ -204,8 +204,8 @@ export function mappedConcat(strings: EitherString[]): MappedString {
204204
};
205205
}
206206

207-
// mapped version of text.ts:indexToRowCol
208-
export function mappedIndexToRowCol(eitherText: EitherString) {
207+
// mapped version of text.ts:indexToLineCol
208+
export function mappedIndexToLineCol(eitherText: EitherString) {
209209
const text = asMappedString(eitherText);
210210

211211
return function (offset: number) {
@@ -215,7 +215,7 @@ export function mappedIndexToRowCol(eitherText: EitherString) {
215215
}
216216
const { index, originalString } = mapResult;
217217

218-
return unmappedIndexToRowCol(originalString.value)(index);
218+
return unmappedIndexToLineCol(originalString.value)(index);
219219
};
220220
}
221221

src/core/lib/text.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function* lineBreakPositions(text: string) {
4343
}
4444
}
4545

46-
export function indexToRowCol(text: string) {
46+
export function indexToLineCol(text: string) {
4747
const offsets = Array.from(lineOffsets(text));
4848
return function (offset: number) {
4949
if (offset === 0) {
@@ -61,10 +61,10 @@ export function indexToRowCol(text: string) {
6161
};
6262
}
6363

64-
export function rowColToIndex(text: string) {
64+
export function lineColToIndex(text: string) {
6565
const offsets = Array.from(lineOffsets(text));
66-
return function (position: { row: number; column: number }) {
67-
return offsets[position.row] + position.column;
66+
return function (position: { line: number; column: number }) {
67+
return offsets[position.line] + position.column;
6868
};
6969
}
7070

src/core/lib/yaml-intelligence/annotated-yaml.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
*
66
*/
77

8-
import { lines, matchAll, rowColToIndex } from "../text.ts";
8+
import { lineColToIndex, lines, matchAll } from "../text.ts";
99
import { AnnotatedParse, JSONValue } from "../yaml-schema/types.ts";
1010

1111
import {
1212
asMappedString,
13-
mappedIndexToRowCol,
13+
mappedIndexToLineCol,
1414
MappedString,
1515
} from "../mapped-text.ts";
1616
import { getTreeSitterSync } from "./parsing.ts";
@@ -52,11 +52,11 @@ export function readAnnotatedYamlFromMappedString(
5252
} catch (e) {
5353
const m = e.stack.split("\n")[0].match(/^.+ \((\d+):(\d+)\)$/);
5454
if (m) {
55-
const f = rowColToIndex(mappedSource.value);
56-
const offset = f({ row: Number(m[1]) - 1, column: Number(m[2] - 1) });
55+
const f = lineColToIndex(mappedSource.value);
56+
const offset = f({ line: Number(m[1]) - 1, column: Number(m[2] - 1) });
5757
const { originalString } = mappedSource.map(offset, true)!;
5858
const filename = originalString.fileName!;
59-
const f2 = mappedIndexToRowCol(mappedSource);
59+
const f2 = mappedIndexToLineCol(mappedSource);
6060
const { line, column } = f2(offset);
6161
const sourceContext = createSourceContext(mappedSource, {
6262
start: offset,

src/core/lib/yaml-intelligence/hover.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { asMappedString } from "../mapped-text.ts";
1111
import { MappedString } from "../text-types.ts";
1212
import { kLangCommentChars } from "../partition-cell-options.ts";
1313
import { rangedLines } from "../ranged-text.ts";
14-
import { indexToRowCol, lines } from "../text.ts";
14+
import { indexToLineCol, lines } from "../text.ts";
1515
import { navigateSchemaByInstancePath } from "../yaml-validation/schema-navigation.ts";
1616
import {
1717
AnnotatedParse,
@@ -78,7 +78,7 @@ function buildLineMap(
7878
}
7979
};
8080

81-
const f = indexToRowCol(document.value);
81+
const f = indexToLineCol(document.value);
8282
const state: State = {
8383
annotation,
8484
path: [],

src/core/lib/yaml-intelligence/parsing.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { asMappedString, MappedString, mappedString } from "../mapped-text.ts";
99
import { rangedLines } from "../ranged-text.ts";
10-
import { lines, rowColToIndex } from "../text.ts";
10+
import { lineColToIndex, lines } from "../text.ts";
1111
import {
1212
LocateFromIndentationContext,
1313
YamlIntelligenceContext,
@@ -112,7 +112,7 @@ export function* attemptParsesAtLine(
112112
const currentLine = codeLines[position.row].substring;
113113
let currentColumn = position.column;
114114
let deletions = 0;
115-
const locF = rowColToIndex(code.value);
115+
const locF = lineColToIndex(code.value);
116116

117117
while (currentColumn > 0) {
118118
currentColumn--;
@@ -128,15 +128,15 @@ export function* attemptParsesAtLine(
128128

129129
if (position.column > deletions) {
130130
chunks.push({
131-
start: locF({ row: position.row, column: 0 }),
132-
end: locF({ row: position.row, column: position.column - deletions }),
131+
start: locF({ line: position.row, column: 0 }),
132+
end: locF({ line: position.row, column: position.column - deletions }),
133133
});
134134
}
135135

136136
if (position.row + 1 < codeLines.length) {
137137
chunks.push({
138-
start: locF({ row: position.row, column: currentLine.length - 1 }),
139-
end: locF({ row: position.row + 1, column: 0 }),
138+
start: locF({ line: position.row, column: currentLine.length - 1 }),
139+
end: locF({ line: position.row + 1, column: 0 }),
140140
});
141141
chunks.push({
142142
start: codeLines[position.row + 1].range.start,

src/core/lib/yaml-intelligence/yaml-intelligence.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { initState, setInitializer } from "../yaml-validation/state.ts";
2020

2121
import { guessChunkOptionsFormat } from "../guess-chunk-options-format.ts";
2222
import { asMappedString, MappedString, mappedString } from "../mapped-text.ts";
23-
import { lines, rowColToIndex } from "../text.ts";
23+
import { lineColToIndex, lines } from "../text.ts";
2424
import { breakQuartoMd, QuartoMdCell } from "../break-quarto-md.ts";
2525
import { rangedLines } from "../ranged-text.ts";
2626
import {
@@ -45,7 +45,7 @@ import {
4545
walkSchema,
4646
} from "../yaml-validation/schema-utils.ts";
4747

48-
import { mappedIndexToRowCol } from "../mapped-text.ts";
48+
import { mappedIndexToLineCol } from "../mapped-text.ts";
4949

5050
import { lineOffsets } from "../text.ts";
5151

@@ -207,7 +207,7 @@ export async function validationFromGoodParseYAML(
207207
if (code.value === "") {
208208
return [];
209209
}
210-
const locF = mappedIndexToRowCol(code);
210+
const locF = mappedIndexToLineCol(code);
211211

212212
// ignore bad lookups (from empty lines at the end of file)
213213
const ls = Array
@@ -327,8 +327,8 @@ async function completionsFromGoodParseYAML(context: YamlIntelligenceContext) {
327327
if (doc === null) {
328328
continue;
329329
}
330-
const index = rowColToIndex(mappedCode.value)({
331-
row: position.row,
330+
const index = lineColToIndex(mappedCode.value)({
331+
line: position.row,
332332
column: position.column - deletions,
333333
});
334334
let { withError: locateFailed, value: maybePath } = locateCursor(

src/core/lib/yaml-validation/errors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from "../errors.ts";
2121

2222
import {
23-
mappedIndexToRowCol,
23+
mappedIndexToLineCol,
2424
MappedString,
2525
mappedString,
2626
Range,
@@ -378,7 +378,7 @@ function expandEmptySpan(
378378
parse,
379379
true,
380380
)!;
381-
const locF = mappedIndexToRowCol(parse.source);
381+
const locF = mappedIndexToLineCol(parse.source);
382382
try {
383383
const location = {
384384
start: locF(lastKey.start),
@@ -769,7 +769,7 @@ export function createSourceContext(
769769
const startMapResult = src.map(location.start, true);
770770
const endMapResult = src.map(location.end, true);
771771

772-
const locF = mappedIndexToRowCol(src);
772+
const locF = mappedIndexToLineCol(src);
773773

774774
let sourceLocation;
775775
try {
@@ -856,7 +856,7 @@ export function createLocalizedError(obj: {
856856
message,
857857
schema,
858858
} = obj;
859-
const locF = mappedIndexToRowCol(source);
859+
const locF = mappedIndexToLineCol(source);
860860

861861
let location;
862862
try {

src/core/mapped-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type StringChunk = mt.StringChunk;
2121
export {
2222
asMappedString,
2323
mappedConcat,
24-
mappedIndexToRowCol,
24+
mappedIndexToLineCol,
2525
mappedNormalizeNewlines,
2626
mappedString,
2727
skipRegexp,

src/core/text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { lines } from "./lib/text.ts";
1212

1313
// reexports from lib
1414
export {
15-
indexToRowCol,
15+
indexToLineCol,
1616
lineBreakPositions,
1717
lineOffsets,
1818
lines,

0 commit comments

Comments
 (0)