Skip to content

Respect original EndOfLine in file, while load changes from server #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- created
jobs:
build:
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function loadChanges(files: CurrentFile[]): Promise<any> {
api
.getDoc(file.name)
.then((data) => {
const content = (data.result.content || []).join("\n");
const content = (data.result.content || []).join(file.eol === vscode.EndOfLine.LF ? "\n" : "\r\n");
if (file.uri.scheme === "file") {
fs.writeFileSync(file.fileName, content);
} else if (file.uri.scheme === FILESYSTEM_SCHEMA) {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface CurrentFile {
fileName: string;
content: string;
uri: vscode.Uri;
eol: vscode.EndOfLine;
}

export function currentFile(document?: vscode.TextDocument): CurrentFile {
Expand All @@ -36,6 +37,7 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
) {
return null;
}
const eol = document.eol || vscode.EndOfLine.LF;
const uri = document.uri;
const fileName = document.fileName;
const content = document.getText();
Expand Down Expand Up @@ -69,6 +71,7 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
fileName,
name,
uri,
eol,
};
}

Expand Down