Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
umpox committed Feb 14, 2025
1 parent 247d708 commit dd2afc1
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 3 deletions.
34 changes: 33 additions & 1 deletion vscode/src/autoedits/renderer/decorators/default-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,19 @@ export class DefaultDecorator implements AutoEditsDecorator {
// Ideally this will follow the exact window.devicePixelRatio value.
// To get that we need to retrieve the value from the webview.
// This is a fallback compromise that works for both high and low DPI.
const pixelRatio = 1.99
const pixelRatio = 1.95
const { dark, light } = generateSuggestionAsImage({
decorations: blockifiedAddedLines,
lang: this.editor.document.languageId,
config: { pixelRatio },
})

const secondImage = generateSuggestionAsImage({
decorations: blockifiedAddedLines,
lang: this.editor.document.languageId,
config: { pixelRatio: 2 },
})

const startLineEndColumn = this.getEndColumn(this.editor.document.lineAt(startLine))

// The padding in which to offset the decoration image away from neighbouring code
Expand Down Expand Up @@ -426,6 +433,31 @@ export class DefaultDecorator implements AutoEditsDecorator {
light: { before: { contentIconPath: vscode.Uri.parse(light) } },
},
},
{
range: new vscode.Range(
startLine + 5,
startLineEndColumn,
startLine + 5,
startLineEndColumn
),
renderOptions: {
before: {
color: new vscode.ThemeColor('editorSuggestWidget.foreground'),
backgroundColor: new vscode.ThemeColor('editorSuggestWidget.background'),
border: '1px solid',
borderColor: new vscode.ThemeColor('editorSuggestWidget.border'),
textDecoration: `none;${decorationStyle}`,
margin: `0 0 0 ${decorationMargin + 8}ch`,
},
after: {
contentText: '\u00A0'.repeat(3) + '\u00A0'.repeat(startLineEndColumn),
margin: `0 0 0 ${decorationMargin + 8}ch`,
},
// Provide different highlighting for dark/light themes
dark: { before: { contentIconPath: vscode.Uri.parse(secondImage.dark) } },
light: { before: { contentIconPath: vscode.Uri.parse(secondImage.light) } },
},
},
])
this.editor.setDecorations(this.insertMarkerDecorationType, [
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions vscode/src/autoedits/renderer/image-gen/canvas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ export function drawDecorationsToCanvas(
const canvasWidth = Math.min(requiredWidth + config.padding.x, config.maxWidth)
const canvasHeight = tempYPos + config.padding.y

const height = Math.round(canvasHeight * config.pixelRatio)
const width = Math.round(canvasWidth * config.pixelRatio)
// Now we create the actual canvas, ensuring we scale it accordingly to improve the output resolution.
const { canvas, ctx } = createCanvas(
{
height: canvasHeight * config.pixelRatio,
width: canvasWidth * config.pixelRatio,
height,
width,
fontSize: config.fontSize,
// We upscale the canvas to improve resolution, this will be brought back to the intended size
// using the `scale` CSS property when the decoration is rendered.
Expand Down
1 change: 1 addition & 0 deletions vscode/src/autoedits/renderer/image-gen/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async function generateImageForTest(
config: {
fontSize: 12,
lineHeight: 18,
pixelRatio: 1.99,
},
})

Expand Down

0 comments on commit dd2afc1

Please sign in to comment.