Skip to content

Commit 29c7b58

Browse files
Merge pull request #109 from ArthurLobopro/feat-limit-line-size
Feat limit line size
2 parents 5286119 + 003f74c commit 29c7b58

File tree

9 files changed

+48
-4
lines changed

9 files changed

+48
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.26.0
2+
3+
Feat: Maximum line width based on characters
4+
15
## 1.25.0
26

37
Feat: Window Container can be resized

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "easy-codesnap",
33
"displayName": "Easy CodeSnap",
44
"description": "Take beautiful screenshots of your code 📷",
5-
"version": "1.25.0",
5+
"version": "1.26.0",
66
"l10n": "./l10n",
77
"repository": {
88
"type": "git",
@@ -267,6 +267,14 @@
267267
"top-right",
268268
"top-left"
269269
]
270+
},
271+
"easy-codesnap.maxCharWidth": {
272+
"order": 25,
273+
"scope": "resource",
274+
"type": "integer",
275+
"default": 0,
276+
"minimum": 0,
277+
"description": "%easy-codesnap.maxCharWidth%"
270278
}
271279
}
272280
}

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
"easy-codesnap.fullLinesSelection": "Does get full line selection when open snap scren",
2727
"easy-codesnap.watermark": "Enable watermark",
2828
"easy-codesnap.defaultWatermarkText": "Default watermark text",
29-
"easy-codesnap.watermarkPosition": "Watermark position on screen"
29+
"easy-codesnap.watermarkPosition": "Watermark position on screen",
30+
"easy-codesnap.maxCharWidth": "Maximum line width based on characters. Use value 0 for no limit"
3031
}

package.nls.pt-br.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
"easy-codesnap.fullLinesSelection": "Selecionar o texto completo de todas as linhas quando abrir a tela de Snap",
2727
"easy-codesnap.watermark": "Mostrar marca d'água",
2828
"easy-codesnap.defaultWatermarkText": "Texto padrão da marca d'água",
29-
"easy-codesnap.watermarkPosition": "Posição da marca d'água"
29+
"easy-codesnap.watermarkPosition": "Posição da marca d'água",
30+
"easy-codesnap.maxCharWidth": "Tamanho máximo da linha baseado em caracteres. Use o valor 0 para não limitar"
3031
}

src/commands/snap/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ export class SnapCommand extends Command {
4141

4242
activeEditor.selection = new vscode.Selection(
4343
new vscode.Position(selection.start.line, 0),
44-
selection.isReversed ? selection.anchor : selection.active,
44+
new vscode.Position(
45+
selection.end.line,
46+
activeEditor.document.lineAt(selection.end.line).text.length,
47+
),
4548
);
4649
}
4750
}

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ export const extensionSettingsNames: ConfigKey[] = [
3030
"watermark",
3131
"defaultWatermarkText",
3232
"watermarkPosition",
33+
"maxCharWidth",
3334
] as const;

src/types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface ExtensionConfig {
1818
highlightLineNumber: boolean;
1919
watermark: boolean;
2020

21+
maxCharWidth: number;
22+
2123
saveScale: 0.5 | 0.75 | 1 | 1.5 | 2 | 3 | 4;
2224
roundingLevel: 1 | 2 | 3 | 4;
2325
saveFormat: "png" | "svg";

src/webview/ui/updaters/VarUpdater.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class VarUpdater extends Updater {
1717
"showLineNumbers",
1818
"letterSpacing",
1919
"target",
20+
"maxCharWidth",
2021
]);
2122
}
2223

@@ -33,6 +34,7 @@ export class VarUpdater extends Updater {
3334
showLineNumbers,
3435
letterSpacing,
3536
target,
37+
maxCharWidth,
3638
} = SessionConfig.get();
3739

3840
setVar("ligatures", fontLigatures ? "normal" : "none");
@@ -55,6 +57,11 @@ export class VarUpdater extends Updater {
5557

5658
setVar("line-number-visibility", showLineNumbers ? "block" : "none");
5759

60+
setVar(
61+
"max-char-width",
62+
maxCharWidth === 0 ? "100%" : `${maxCharWidth.toFixed(0)}ch`,
63+
);
64+
5865
snippetContainerNode.dataset.enableresizing = String(enableResizing);
5966
snippetContainerNode.dataset.target = target;
6067
}

webview/styles/original-style.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ html {
88
--window-border-radius: 4px;
99
--letter-spacing: 0px;
1010
--zoom: 100%;
11+
--max-char-width: 100%
1112

1213
box-sizing: border-box;
1314
}
@@ -82,6 +83,10 @@ div:has(#snippet-scroll) {
8283
padding: 18px;
8384
background-color: var(--vscode-editor-background);
8485
box-sizing: border-box;
86+
87+
* {
88+
box-sizing: border-box;
89+
}
8590
}
8691

8792
#snippet {
@@ -114,6 +119,18 @@ div:has(#snippet-scroll) {
114119
display: flex;
115120
flex-wrap: wrap;
116121
width: 100%;
122+
123+
>span {
124+
display: flex;
125+
width: 100%;
126+
flex-wrap: wrap;
127+
max-width: var(--max-char-width);
128+
129+
>span {
130+
white-space: pre;
131+
width: max-content;
132+
}
133+
}
117134
}
118135

119136
#save-container {

0 commit comments

Comments
 (0)