Открыть боковую панель
code
vscode
Коммиты
4849dcc8
Не подтверждена
Коммит
4849dcc8
создал
5 мес. назад
по автору
Johannes Rieken
Зафиксировано автором
GitHub
5 мес. назад
Просмотр файлов
Настройки
Скачать
Простое отличие
Merge branch 'main' into joh/aggregate-amphibian
владельцы
07d716a9
71b2684d
Branches недоступно
Не найдено связанных запросов на слияние
Изменения
3
Скрыть пробелы
Построчно
Рядом
Отображение
3 измененных файлов
src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts
+26
-28
...rowser/controller/editContext/native/nativeEditContext.ts
src/vs/editor/browser/controller/editContext/native/nativeEditContextUtils.ts
+5
-80
...r/controller/editContext/native/nativeEditContextUtils.ts
src/vs/editor/browser/controller/editContext/native/screenReaderSupport.ts
+7
-4
...wser/controller/editContext/native/screenReaderSupport.ts
с
38 дополнений
и
112 удаления
+38
-112
src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts
+
26
-
28
Просмотр файла @
4849dcc8
...
...
@@ -21,7 +21,7 @@ import { RestrictedRenderingContext, RenderingContext } from '../../../view/rend
import
{
ViewController
}
from
'
../../../view/viewController.js
'
;
import
{
ClipboardStoredMetadata
,
getDataToCopy
,
InMemoryClipboardMetadataManager
}
from
'
../clipboardUtils.js
'
;
import
{
AbstractEditContext
}
from
'
../editContextUtils.js
'
;
import
{
E
ditContext
Wrapp
er
,
FocusTracker
}
from
'
./nativeEditContextUtils.js
'
;
import
{
e
ditContext
AddDisposableListen
er
,
FocusTracker
,
ITypeData
}
from
'
./nativeEditContextUtils.js
'
;
import
{
ScreenReaderSupport
}
from
'
./screenReaderSupport.js
'
;
import
{
Range
}
from
'
../../../../common/core/range.js
'
;
import
{
Selection
}
from
'
../../../../common/core/selection.js
'
;
...
...
@@ -30,7 +30,7 @@ import { Position } from '../../../../common/core/position.js';
export
class
NativeEditContext
extends
AbstractEditContext
{
public
readonly
domNode
:
FastDomNode
<
HTMLDivElement
>
;
private
readonly
_editContext
:
EditContext
Wrapper
;
private
readonly
_editContext
:
EditContext
;
private
readonly
_screenReaderSupport
:
ScreenReaderSupport
;
// Overflow guard container
...
...
@@ -39,6 +39,9 @@ export class NativeEditContext extends AbstractEditContext {
private
_renderingContext
:
RenderingContext
|
undefined
;
private
_primarySelection
:
Selection
=
new
Selection
(
1
,
1
,
1
,
1
);
private
_textStartPositionWithinEditor
:
Position
=
new
Position
(
1
,
1
);
private
_compositionRangeWithinEditor
:
Range
|
undefined
;
private
readonly
_focusTracker
:
FocusTracker
;
constructor
(
...
...
@@ -55,9 +58,8 @@ export class NativeEditContext extends AbstractEditContext {
this
.
_focusTracker
=
this
.
_register
(
new
FocusTracker
(
this
.
domNode
.
domNode
,
(
newFocusValue
:
boolean
)
=>
this
.
_context
.
viewModel
.
setHasFocus
(
newFocusValue
)));
const
editContext
=
new
EditContext
();
this
.
domNode
.
domNode
.
editContext
=
editContext
;
this
.
_editContext
=
new
EditContextWrapper
(
editContext
);
this
.
_editContext
=
new
EditContext
();
this
.
domNode
.
domNode
.
editContext
=
this
.
_editContext
;
this
.
_screenReaderSupport
=
instantiationService
.
createInstance
(
ScreenReaderSupport
,
this
.
domNode
,
context
);
...
...
@@ -87,30 +89,33 @@ export class NativeEditContext extends AbstractEditContext {
}));
// Edit context events
this
.
_register
(
this
.
_editContext
.
onT
ext
F
ormat
U
pdate
(
e
=>
this
.
_handleTextFormatUpdate
(
e
)));
this
.
_register
(
this
.
_editContext
.
onC
haracter
B
ounds
U
pdate
(
e
=>
this
.
_updateCharacterBounds
()));
this
.
_register
(
this
.
_editContext
.
onT
ext
U
pdate
(
e
=>
{
const
compositionRangeWithinEditor
=
this
.
_
editContext
.
compositionRangeWithinEditor
;
this
.
_register
(
editContextAddDisposableListener
(
this
.
_editContext
,
'
t
ext
f
ormat
u
pdate
'
,
(
e
)
=>
this
.
_handleTextFormatUpdate
(
e
)));
this
.
_register
(
editContextAddDisposableListener
(
this
.
_editContext
,
'
c
haracter
b
ounds
u
pdate
'
,
(
e
)
=>
this
.
_updateCharacterBounds
()));
this
.
_register
(
editContextAddDisposableListener
(
this
.
_editContext
,
'
t
ext
u
pdate
'
,
(
e
)
=>
{
const
compositionRangeWithinEditor
=
this
.
_compositionRangeWithinEditor
;
if
(
compositionRangeWithinEditor
)
{
const
position
=
this
.
_context
.
viewModel
.
getPrimaryCursorState
().
viewState
.
position
;
const
newCompositionRangeWithinEditor
=
Range
.
fromPositions
(
compositionRangeWithinEditor
.
getStartPosition
(),
position
);
this
.
_
editContext
.
updateC
ompositionRangeWithinEditor
(
newCompositionRangeWithinEditor
)
;
this
.
_
c
ompositionRangeWithinEditor
=
newCompositionRangeWithinEditor
;
}
this
.
_emitTypeEvent
(
viewController
,
e
);
// this._screenReaderSupport.writeScreenReaderContent();
// TODO @aiday-mar calling write screen reader content so that the document selection is immediately set
// remove the following when electron will be upgraded
this
.
_screenReaderSupport
.
writeScreenReaderContent
();
}));
this
.
_register
(
this
.
_editContext
.
onC
omposition
S
tart
(
e
=>
{
this
.
_register
(
editContextAddDisposableListener
(
this
.
_editContext
,
'
c
omposition
s
tart
'
,
(
e
)
=>
{
const
position
=
this
.
_context
.
viewModel
.
getPrimaryCursorState
().
viewState
.
position
;
const
newCompositionRange
=
Range
.
fromPositions
(
position
,
position
);
this
.
_
editContext
.
updateC
ompositionRangeWithinEditor
(
newCompositionRange
)
;
this
.
_
c
ompositionRangeWithinEditor
=
newCompositionRange
;
// Utlimately fires onDidCompositionStart() on the editor to notify for example suggest model of composition state
// Updates the composition state of the cursor controller which determines behavior of typing with interceptors
viewController
.
compositionStart
();
// Emits ViewCompositionStartEvent which can be depended on by ViewEventHandlers
this
.
_context
.
viewModel
.
onCompositionStart
();
}));
this
.
_register
(
this
.
_editContext
.
onC
omposition
E
nd
(
e
=>
{
this
.
_
editContext
.
updateC
ompositionRangeWithinEditor
(
undefined
)
;
this
.
_register
(
editContextAddDisposableListener
(
this
.
_editContext
,
'
c
omposition
e
nd
'
,
(
e
)
=>
{
this
.
_
c
ompositionRangeWithinEditor
=
undefined
;
// Utlimately fires compositionEnd() on the editor to notify for example suggest model of composition state
// Updates the composition state of the cursor controller which determines behavior of typing with interceptors
viewController
.
compositionEnd
();
...
...
@@ -186,7 +191,7 @@ export class NativeEditContext extends AbstractEditContext {
const
editContextState
=
this
.
_getNewEditContextState
();
this
.
_editContext
.
updateText
(
0
,
Number
.
MAX_SAFE_INTEGER
,
editContextState
.
text
);
this
.
_editContext
.
updateSelection
(
editContextState
.
selectionStartOffset
,
editContextState
.
selectionEndOffset
);
this
.
_
editContext
.
updateT
extStartPositionWithinEditor
(
editContextState
.
textStartPositionWithinEditor
)
;
this
.
_
t
extStartPositionWithinEditor
=
editContextState
.
textStartPositionWithinEditor
;
}
private
_emitTypeEvent
(
viewController
:
ViewController
,
e
:
TextUpdateEvent
):
void
{
...
...
@@ -194,7 +199,7 @@ export class NativeEditContext extends AbstractEditContext {
return
;
}
const
model
=
this
.
_context
.
viewModel
.
model
;
const
offsetOfStartOfText
=
model
.
getOffsetAt
(
this
.
_
editContext
.
textStartPositionWithinEditor
);
const
offsetOfStartOfText
=
model
.
getOffsetAt
(
this
.
_textStartPositionWithinEditor
);
const
offsetOfSelectionEnd
=
model
.
getOffsetAt
(
this
.
_primarySelection
.
getEndPosition
());
const
offsetOfSelectionStart
=
model
.
getOffsetAt
(
this
.
_primarySelection
.
getStartPosition
());
const
selectionEndOffset
=
offsetOfSelectionEnd
-
offsetOfStartOfText
;
...
...
@@ -277,7 +282,7 @@ export class NativeEditContext extends AbstractEditContext {
return
;
}
const
formats
=
e
.
getTextFormats
();
const
textStartPositionWithinEditor
=
this
.
_
editContext
.
textStartPositionWithinEditor
;
const
textStartPositionWithinEditor
=
this
.
_textStartPositionWithinEditor
;
const
decorations
:
IModelDeltaDecoration
[]
=
[];
formats
.
forEach
(
f
=>
{
const
textModel
=
this
.
_context
.
viewModel
.
model
;
...
...
@@ -336,14 +341,14 @@ export class NativeEditContext extends AbstractEditContext {
}
private
_updateCharacterBounds
()
{
if
(
!
this
.
_parent
||
!
this
.
_
editContext
.
compositionRangeWithinEditor
)
{
if
(
!
this
.
_parent
||
!
this
.
_compositionRangeWithinEditor
)
{
return
;
}
const
options
=
this
.
_context
.
configuration
.
options
;
const
lineHeight
=
options
.
get
(
EditorOption
.
lineHeight
);
const
contentLeft
=
options
.
get
(
EditorOption
.
layoutInfo
).
contentLeft
;
const
parentBounds
=
this
.
_parent
.
getBoundingClientRect
();
const
compositionRangeWithinEditor
=
this
.
_
editContext
.
compositionRangeWithinEditor
;
const
compositionRangeWithinEditor
=
this
.
_compositionRangeWithinEditor
;
const
verticalOffsetStartOfComposition
=
this
.
_context
.
viewLayout
.
getVerticalOffsetForLineNumber
(
compositionRangeWithinEditor
.
startLineNumber
);
const
editorScrollTop
=
this
.
_context
.
viewLayout
.
getCurrentScrollTop
();
const
top
=
parentBounds
.
top
+
verticalOffsetStartOfComposition
-
editorScrollTop
;
...
...
@@ -358,7 +363,7 @@ export class NativeEditContext extends AbstractEditContext {
}
}
const
textModel
=
this
.
_context
.
viewModel
.
model
;
const
offsetOfEditContextStart
=
textModel
.
getOffsetAt
(
this
.
_
editContext
.
textStartPositionWithinEditor
);
const
offsetOfEditContextStart
=
textModel
.
getOffsetAt
(
this
.
_textStartPositionWithinEditor
);
const
offsetOfCompositionStart
=
textModel
.
getOffsetAt
(
compositionRangeWithinEditor
.
getStartPosition
());
const
offsetOfCompositionStartInEditContext
=
offsetOfCompositionStart
-
offsetOfEditContextStart
;
this
.
_editContext
.
updateCharacterBounds
(
offsetOfCompositionStartInEditContext
,
characterBounds
);
...
...
@@ -385,10 +390,3 @@ export class NativeEditContext extends AbstractEditContext {
clipboardService
.
writeText
(
dataToCopy
.
text
);
}
}
interface
ITypeData
{
text
:
string
;
replacePrevCharCnt
:
number
;
replaceNextCharCnt
:
number
;
positionDelta
:
number
;
}
This diff is collapsed.
Click to expand it.
src/vs/editor/browser/controller/editContext/native/nativeEditContextUtils.ts
+
5
-
80
Просмотр файла @
4849dcc8
...
...
@@ -5,87 +5,12 @@
import
{
addDisposableListener
}
from
'
../../../../../base/browser/dom.js
'
;
import
{
IDisposable
,
Disposable
}
from
'
../../../../../base/common/lifecycle.js
'
;
import
{
Position
}
from
'
../../../../common/core/position.js
'
;
import
{
Range
}
from
'
../../../../common/core/range.js
'
;
export
class
EditContextWrapper
{
private
_textStartPositionWithinEditor
:
Position
=
new
Position
(
1
,
1
);
private
_compositionRangeWithinEditor
:
Range
|
undefined
;
constructor
(
private
readonly
_editContext
:
EditContext
)
{
}
onTextUpdate
(
listener
:
(
this
:
GlobalEventHandlers
,
ev
:
TextUpdateEvent
)
=>
void
)
{
return
editContextAddDisposableListener
(
this
.
_editContext
,
'
textupdate
'
,
listener
);
}
onCompositionStart
(
listener
:
(
this
:
GlobalEventHandlers
,
ev
:
Event
)
=>
void
)
{
return
editContextAddDisposableListener
(
this
.
_editContext
,
'
compositionstart
'
,
listener
);
}
onCompositionEnd
(
listener
:
(
this
:
GlobalEventHandlers
,
ev
:
Event
)
=>
void
)
{
return
editContextAddDisposableListener
(
this
.
_editContext
,
'
compositionend
'
,
listener
);
}
onCharacterBoundsUpdate
(
listener
:
(
this
:
GlobalEventHandlers
,
ev
:
CharacterBoundsUpdateEvent
)
=>
void
)
{
return
editContextAddDisposableListener
(
this
.
_editContext
,
'
characterboundsupdate
'
,
listener
);
}
onTextFormatUpdate
(
listener
:
(
this
:
GlobalEventHandlers
,
ev
:
TextFormatUpdateEvent
)
=>
void
)
{
return
editContextAddDisposableListener
(
this
.
_editContext
,
'
textformatupdate
'
,
listener
);
}
updateText
(
rangeStart
:
number
,
rangeEnd
:
number
,
text
:
string
):
void
{
this
.
_editContext
.
updateText
(
rangeStart
,
rangeEnd
,
text
);
}
updateSelection
(
selectionStart
:
number
,
selectionEnd
:
number
):
void
{
this
.
_editContext
.
updateSelection
(
selectionStart
,
selectionEnd
);
}
updateControlBounds
(
controlBounds
:
DOMRect
):
void
{
this
.
_editContext
.
updateControlBounds
(
controlBounds
);
}
updateSelectionBounds
(
selectionBounds
:
DOMRect
):
void
{
this
.
_editContext
.
updateSelectionBounds
(
selectionBounds
);
}
updateCharacterBounds
(
rangeStart
:
number
,
characterBounds
:
DOMRect
[]):
void
{
this
.
_editContext
.
updateCharacterBounds
(
rangeStart
,
characterBounds
);
}
updateTextStartPositionWithinEditor
(
textStartPositionWithinEditor
:
Position
):
void
{
this
.
_textStartPositionWithinEditor
=
textStartPositionWithinEditor
;
}
updateCompositionRangeWithinEditor
(
compositionRange
:
Range
|
undefined
):
void
{
this
.
_compositionRangeWithinEditor
=
compositionRange
;
}
public
get
text
():
string
{
return
this
.
_editContext
.
text
;
}
public
get
selectionStart
():
number
{
return
this
.
_editContext
.
selectionStart
;
}
public
get
selectionEnd
():
number
{
return
this
.
_editContext
.
selectionEnd
;
}
public
get
characterBounds
():
DOMRect
[]
{
return
this
.
_editContext
.
characterBounds
();
}
public
get
textStartPositionWithinEditor
():
Position
{
return
this
.
_textStartPositionWithinEditor
;
}
public
get
compositionRangeWithinEditor
():
Range
|
undefined
{
return
this
.
_compositionRangeWithinEditor
;
}
export
interface
ITypeData
{
text
:
string
;
replacePrevCharCnt
:
number
;
replaceNextCharCnt
:
number
;
positionDelta
:
number
;
}
export
class
FocusTracker
extends
Disposable
{
...
...
This diff is collapsed.
Click to expand it.
src/vs/editor/browser/controller/editContext/native/screenReaderSupport.ts
+
7
-
4
Просмотр файла @
4849dcc8
...
...
@@ -113,9 +113,12 @@ export class ScreenReaderSupport {
private
_getScreenReaderContentState
():
ScreenReaderContentState
|
undefined
{
// Make the screen reader content always be visible because of the bug and also set the selection
if
(
this
.
_accessibilitySupport
===
AccessibilitySupport
.
Disabled
)
{
return
;
}
// TODO @aiday-mar Ultimately uncomment this code when Electron will be upgraded
// if (this._accessibilitySupport === AccessibilitySupport.Disabled) {
// return;
// }
const
accessibilityPageSize
=
this
.
_accessibilitySupport
===
AccessibilitySupport
.
Disabled
?
1
:
this
.
_accessibilityPageSize
;
const
simpleModel
:
ISimpleModel
=
{
getLineCount
:
():
number
=>
{
return
this
.
_context
.
viewModel
.
getLineCount
();
...
...
@@ -133,7 +136,7 @@ export class ScreenReaderSupport {
return
this
.
_context
.
viewModel
.
modifyPosition
(
position
,
offset
);
}
};
return
PagedScreenReaderStrategy
.
fromEditorSelection
(
simpleModel
,
this
.
_primarySelection
,
this
.
_
accessibilityPageSize
,
this
.
_accessibilitySupport
===
AccessibilitySupport
.
Unknown
);
return
PagedScreenReaderStrategy
.
fromEditorSelection
(
simpleModel
,
this
.
_primarySelection
,
accessibilityPageSize
,
this
.
_accessibilitySupport
===
AccessibilitySupport
.
Unknown
);
}
private
_setSelectionOfScreenReaderContent
(
selectionOffsetStart
:
number
,
selectionOffsetEnd
:
number
):
void
{
...
...
This diff is collapsed.
Click to expand it.
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать
Меню
Проекты
Группы
Сниппеты