Skip to content
New issue

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

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

Already on GitHub? # to your account

Do not permit secretpeeking during autocompletion (when turned off) #97

Merged
merged 2 commits into from
Jun 15, 2023
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
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

All notable changes to the Official Dotenv VS Code extension will be documented in this file.

## [Unreleased](https://github.com/dotenv-org/dotenv-vscode/compare/v0.24.3...master)
## [Unreleased](https://github.com/dotenv-org/dotenv-vscode/compare/v0.27.2...master)

## 0.27.1
## [0.27.2](https://github.com/dotenv-org/dotenv-vscode/compare/v0.27.2...v0.27.1) (2023-06-15)

### Added

* For autocompletion, respect secret peeking setting off or on [#97](https://github.com/dotenv-org/dotenv-vscode/pull/97)

## [0.27.1](https://github.com/dotenv-org/dotenv-vscode/compare/v0.27.1...v0.27.0) (2023-06-15)

### Changed

* `await` for async function to set `files.associations` in extension.js

## 0.27.0
## [0.27.0](https://github.com/dotenv-org/dotenv-vscode/compare/v0.27.0...v0.26.0) (2023-06-15)

### Added

Expand Down
31 changes: 19 additions & 12 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,40 @@ function autocomplete (triggerCharacter, document, position) {
return entries.map(function (env) {
const key = env[0].trim()
const value = env[1].trim()
let formattedValue = settings.missingText()

if (value) {
if (settings.secretpeekingEnabled()) {
formattedValue = value
} else {
formattedValue = _partialMask(value)
}
}

// https://code.visualstudio.com/api/references/vscode-api#CompletionItemLabel
const completionItemLabel = {
label: key,
detail: ` ${value}`
// detail: ` ${value}`
detail: ` ${formattedValue}`
}
const item = new vscode.CompletionItem(completionItemLabel, vscode.CompletionItemKind.Variable)
item.insertText = `${triggerCharacter}${quote}${key}${quote}`
item.filterText = `${triggerCharacter}${quote}${key}${quote}`
item.range = new vscode.Range(new vscode.Position(position.line, position.character - 1), position) // Picks up trigger character as prefix to fix the scoring it does when sorting
item.sortText = '0' // Make this the sortText so that any ENV variables will go to the top of the list above anything else
if (!value) {
// do nothing
} else {
const s = `.env

const s = `.env
<hr/>

**${key}**

<pre><code>${value}</code></pre>
<pre><code>${formattedValue}</code></pre>
`
const doc = new vscode.MarkdownString(s)
doc.value = s
doc.supportHtml = true
// item.documentation = value // update with more details
item.documentation = doc // more details
}
const doc = new vscode.MarkdownString(s)
doc.value = s
doc.supportHtml = true
// item.documentation = value // update with more details
item.documentation = doc // more details

return item
})
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Dotenv Official +Vault",
"description": "Official Dotenv. Syntax highlighting, auto-cloaking, auto-completion, in-code secret peeking, and optionally dotenv-vault.",
"author": "Mot @motdotla",
"version": "0.27.1",
"version": "0.27.2",
"license": "MIT",
"homepage": "https://github.com/dotenv-org/dotenv-vscode",
"icon": "dotenv.png",
Expand Down