File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
5
5
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/en/1.0.0/ ) \
6
6
7
+ ## Unreleased
8
+
9
+ ### Changed
10
+
11
+ - Reads indentation preferences for current workspace and uses it in instantiate module
12
+
13
+ ### Fixed
14
+
15
+ - Fix by reading preferences from workspace [ #493 ] ( https://github.com/mshr-h/vscode-verilog-hdl-support/issues/493 )
16
+
7
17
## [ 1.15.1] - 2024-08-31
8
18
9
19
### Changed
Original file line number Diff line number Diff line change @@ -73,9 +73,24 @@ async function instantiateModule(srcpath: string): Promise<vscode.SnippetString
73
73
. appendText ( ');\n' ) ;
74
74
}
75
75
76
+ function getIndentationString ( ) : string {
77
+ const editorConfig = vscode . workspace . getConfiguration ( 'editor' ) ;
78
+
79
+ const useSpaces = editorConfig . get < boolean > ( 'insertSpaces' , true ) ;
80
+ const tabSize = editorConfig . get < number > ( 'tabSize' , 4 ) ;
81
+
82
+ if ( useSpaces ) {
83
+ return ' ' . repeat ( tabSize ) ;
84
+ } else {
85
+ return '\t' ;
86
+ }
87
+ }
88
+
76
89
function instantiatePort ( ports : string [ ] ) : string {
77
90
let port = '' ;
78
91
let maxLen = 0 ;
92
+ let indent = getIndentationString ( ) ;
93
+
79
94
for ( let i = 0 ; i < ports . length ; i ++ ) {
80
95
if ( ports [ i ] . length > maxLen ) {
81
96
maxLen = ports [ i ] . length ;
@@ -86,7 +101,8 @@ function instantiatePort(ports: string[]): string {
86
101
let element = ports [ i ] ;
87
102
let padding = maxLen - element . length + 1 ;
88
103
element = element + ' ' . repeat ( padding ) ;
89
- port += `\t.${ element } (${ element } )` ;
104
+ port += indent ;
105
+ port += `.${ element } (${ element } )` ;
90
106
if ( i !== ports . length - 1 ) {
91
107
port += ',' ;
92
108
}
You can’t perform that action at this time.
0 commit comments