Skip to content

Commit

Permalink
Fix: Handle "files.trimTrailingWhitespace" settings with embedded lan…
Browse files Browse the repository at this point in the history
…guages
  • Loading branch information
idillon-sfl committed Dec 15, 2023
1 parent bc28db5 commit dc3db6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ user settings.
}
```

Note that the extension deactivates the "files.trimTrailingWhitespace" setting for
Python and Shell script, as it interferes with the functioning of features related
to embedded languages.

## Features

### Syntax highlighting
Expand Down
11 changes: 11 additions & 0 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ function updatePythonPath (): void {
}
}

async function disableInteferingSettings (): Promise<void> {
const config = vscode.workspace.getConfiguration()
for (const languageKey of ['[python]', '[shellscript]']) {
const languageConfig = config.get<Record<string, unknown>>(languageKey) ?? {}
// 'files.trimTrailingWhitespace' modifies the embedded languages documents and breaks the mapping of the positions
languageConfig['files.trimTrailingWhitespace'] = false
await config.update(languageKey, languageConfig, vscode.ConfigurationTarget.Workspace)
}
}

export async function activate (context: vscode.ExtensionContext): Promise<void> {
logger.outputChannel = vscode.window.createOutputChannel('BitBake')

Expand All @@ -60,6 +70,7 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
bitbakeDriver.loadSettings(vscode.workspace.getConfiguration('bitbake'), vscode.workspace.workspaceFolders?.[0].uri.fsPath)
bitBakeProjectScanner.setDriver(bitbakeDriver)
updatePythonPath()
await disableInteferingSettings()
bitbakeWorkspace.loadBitbakeWorkspace(context.workspaceState)
bitbakeTaskProvider = new BitbakeTaskProvider(bitbakeDriver)
client = await activateLanguageServer(context)
Expand Down

0 comments on commit dc3db6b

Please sign in to comment.