未验证 提交 5ff11212 编写于 作者: A Alex Dima

Don't always use the replacement character in minimap

When the font scale is small enough, using other ASCII characters for characters outside the supported ASCII range is preferrable.

Fixes #84264
上级 2bc77436
......@@ -1109,7 +1109,7 @@ export class Minimap extends ViewPart {
if (renderMinimap === RenderMinimap.Blocks) {
minimapCharRenderer.blockRenderChar(target, dx, dy, tokenColor, backgroundColor, useLighterFont);
} else { // RenderMinimap.Text
minimapCharRenderer.renderChar(target, dx, dy, charCode, tokenColor, backgroundColor, useLighterFont);
minimapCharRenderer.renderChar(target, dx, dy, charCode, tokenColor, backgroundColor, fontScale, useLighterFont);
}
dx += charWidth;
......
......@@ -32,6 +32,7 @@ export class MinimapCharRenderer {
chCode: number,
color: RGBA8,
backgroundColor: RGBA8,
fontScale: number,
useLighterFont: boolean
): void {
const charWidth = Constants.BASE_CHAR_WIDTH * this.scale;
......@@ -42,7 +43,7 @@ export class MinimapCharRenderer {
}
const charData = useLighterFont ? this.charDataLight : this.charDataNormal;
const charIndex = getCharIndex(chCode);
const charIndex = getCharIndex(chCode, fontScale);
const destWidth = target.width * Constants.RGBA_CHANNELS_CNT;
......
......@@ -29,9 +29,13 @@ export const allCharCodes: ReadonlyArray<number> = (() => {
return v;
})();
export const getCharIndex = (chCode: number) => {
export const getCharIndex = (chCode: number, fontScale: number) => {
chCode -= Constants.START_CH_CODE;
if (chCode < 0 || chCode > Constants.CHAR_COUNT) {
if (fontScale <= 2) {
// for smaller scales, we can get away with using any ASCII character...
return (chCode + Constants.CHAR_COUNT) % Constants.CHAR_COUNT;
}
return Constants.CHAR_COUNT - 1; // unknown symbol
}
......
......@@ -86,7 +86,7 @@ suite('MinimapCharRenderer', () => {
imageData.data[4 * i + 2] = background.b;
imageData.data[4 * i + 3] = 255;
}
renderer.renderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
renderer.renderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, 2, false);
let actual: number[] = [];
for (let i = 0; i < imageData.data.length; i++) {
......@@ -116,7 +116,7 @@ suite('MinimapCharRenderer', () => {
imageData.data[4 * i + 3] = 255;
}
renderer.renderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
renderer.renderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, 1, false);
let actual: number[] = [];
for (let i = 0; i < imageData.data.length; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册