File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
pyqt_code_editor/components Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -59,12 +59,20 @@ def language(self):
59
59
def get (self ):
60
60
text_cursor = self ._editor .textCursor ()
61
61
if text_cursor .hasSelection ():
62
+ # Move to the start of the first selected block
63
+ start = text_cursor .selectionStart ()
64
+ end = text_cursor .selectionEnd ()
65
+ text_cursor .setPosition (start )
66
+ text_cursor .movePosition (text_cursor .StartOfBlock )
67
+ text_cursor .setPosition (end , text_cursor .KeepAnchor )
68
+ text_cursor .movePosition (text_cursor .EndOfBlock , text_cursor .KeepAnchor )
69
+ self ._editor .setTextCursor (text_cursor )
62
70
content = self ._normalize_line_breaks (text_cursor .selectedText ())
63
71
else :
64
72
content = self ._editor .toPlainText ()
65
73
self ._indentation = self ._get_indentation (content )
66
- logger .info (f'content was indented by "{ self ._indentation } "' )
67
- return content , self ._editor .code_editor_language
74
+ logger .info (f'content was indented by "{ self ._indentation } "' )
75
+ return textwrap . dedent ( content ) , self ._editor .code_editor_language
68
76
69
77
def set (self , content , language ):
70
78
text_cursor = self ._editor .textCursor ()
You can’t perform that action at this time.
0 commit comments