Skip to content

Commit

Permalink
Merge branch '2611-paredit-D' into 2611-paredit-D+2691
Browse files Browse the repository at this point in the history
  • Loading branch information
pbwolf committed Jan 5, 2025
2 parents 1442433 + 1cf9e65 commit be79275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/calva-fmt/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export async function indentPosition(position: vscode.Position, document: vscode
}
}

export async function formatRangeEdits(
export function formatRangeEdits(
document: vscode.TextDocument,
originalRange: vscode.Range
): Promise<vscode.TextEdit[] | undefined> {
): vscode.TextEdit[] | undefined {
const mirrorDoc = getDocument(document);
const startIndex = document.offsetAt(originalRange.start);
const cursor = mirrorDoc.getTokenCursor(startIndex);
Expand All @@ -63,7 +63,7 @@ export async function formatRangeEdits(
const trailingWs = originalText.match(/\s*$/)[0];
const missingTexts = cursorDocUtils.getMissingBrackets(originalText);
const healedText = `${missingTexts.prepend}${originalText.trim()}${missingTexts.append}`;
const formattedHealedText = await formatCode(healedText, document.eol);
const formattedHealedText = formatCode(healedText, document.eol);
const leadingEolPos = leadingWs.lastIndexOf(eol);
const startIndent =
leadingEolPos === -1
Expand All @@ -86,7 +86,7 @@ export async function formatRangeEdits(

export async function formatRange(document: vscode.TextDocument, range: vscode.Range) {
const wsEdit: vscode.WorkspaceEdit = new vscode.WorkspaceEdit();
const edits = await formatRangeEdits(document, range);
const edits = formatRangeEdits(document, range);

if (isUndefined(edits)) {
console.error('formatRangeEdits returned undefined!', cloneDeep({ document, range }));
Expand Down Expand Up @@ -315,11 +315,11 @@ export function trimWhiteSpacePositionCommand(editor: vscode.TextEditor) {
void formatPosition(editor, false, { 'remove-multiple-non-indenting-spaces?': true });
}

export async function formatCode(code: string, eol: number) {
export function formatCode(code: string, eol: number) {
const d = {
'range-text': code,
eol: _convertEolNumToStringNotation(eol),
config: await config.getConfig(),
config: config.getConfigNow(),
};
const result = jsify(formatText(d));
if (!result['error']) {
Expand Down
10 changes: 5 additions & 5 deletions src/repl-window/repl-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export function setNamespaceFromCurrentFile() {
output.replWindowAppendPrompt();
}

async function appendFormGrabbingSessionAndNS(topLevel: boolean) {
function appendFormGrabbingSessionAndNS(topLevel: boolean): void {
const session = replSession.getSession();
const [ns, _] = namespace.getNamespace(
util.tryToGetDocument({}),
Expand All @@ -311,9 +311,9 @@ async function appendFormGrabbingSessionAndNS(topLevel: boolean) {
let code = '';
if (selection.isEmpty) {
const formSelection = select.getFormSelection(doc, selection.active, topLevel);
code = await formatCode(doc.getText(formSelection), doc.eol);
code = formatCode(doc.getText(formSelection), doc.eol);
} else {
code = await formatCode(doc.getText(selection), doc.eol);
code = formatCode(doc.getText(selection), doc.eol);
}
if (code != '') {
setSession(session, ns);
Expand All @@ -322,11 +322,11 @@ async function appendFormGrabbingSessionAndNS(topLevel: boolean) {
}

export function appendCurrentForm() {
void appendFormGrabbingSessionAndNS(false);
appendFormGrabbingSessionAndNS(false);
}

export function appendCurrentTopLevelForm() {
void appendFormGrabbingSessionAndNS(true);
appendFormGrabbingSessionAndNS(true);
}

export async function lastLineIsEmpty(): Promise<boolean> {
Expand Down

0 comments on commit be79275

Please sign in to comment.