Skip to content

Commit c674c69

Browse files
committed
feat: enable format without line break
1 parent 53fbfed commit c674c69

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,12 @@
474474
"minimum": 10,
475475
"maximum": 3600,
476476
"markdownDescription": "%configuration.invisibleMode.inactiveTimeout.markdownDescription%"
477+
},
478+
"overleaf-workshop.formatWithLineBreak.enabled": {
479+
"type": "boolean",
480+
"default": true,
481+
"scope": "machine",
482+
"markdownDescription": "%configuration.formatWithLineBreak.enabled.markdownDescription%"
477483
}
478484
}
479485
},

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"configuration.invisibleMode.historyRefreshInterval.markdownDescription": "The interval (in seconds) to refresh the project history in invisible mode, which is used to update the file changes, collaborator status, etc.",
5959
"configuration.invisibleMode.chatMessageRefreshInterval.markdownDescription": "The interval (in seconds) to refresh the chat messages in invisible mode.",
6060
"configuration.invisibleMode.inactiveTimeout.markdownDescription": "The timeout (in seconds) to mark a online Collaborator as inactivate in invisible mode.",
61+
"configuration.formatWithLineBreak.enabled.markdownDescription": "Enable line breaks when formatting.",
6162

6263
"views.overleaf-workshop.projectManager.name": "Hosts",
6364
"views.explorer.overleaf-workshop.projectHistory": "History",

src/intellisense/texDocumentFormatProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ import { IntellisenseProvider } from '.';
66

77
// https://github.com/siefkenj/latex-parser-playground/blob/master/src/async-worker/parsing-worker.ts#L35-L43
88
async function prettierFormat(text: string, options: vscode.FormattingOptions ) {
9+
10+
const lineBreakEnabled = vscode.workspace.getConfiguration('overleaf-workshop.formatWithLineBreak').get<boolean>('enabled', true);
11+
const printWidth = lineBreakEnabled ? 80 : 10000;
912
return Prettier.format(text, {
1013
parser: "latex-parser",
1114
tabWidth: options.tabSize,
1215
useTabs: !(options.insertSpaces),
1316
plugins: [prettierPluginLatex],
17+
printWidth: printWidth,
1418
});
1519
}
1620

0 commit comments

Comments
 (0)